vba - MS Visio 使用 VBA 拖放自定义形状
问题描述
我似乎无法弄清楚如何使用 VBA 删除形状。
我想做的是:用户打开一个用户窗体并在文本框中输入一些东西。单击命令按钮时,我想从自定义模具(即shapes.vssx)加载形状(即资源),将用户条目写入ShapeData(即在Props.Name中写入名称字符串),然后将其放在某处工作表。我知道我必须使用 Shape.Drop 方法,但是如何引用我想用于创建新形状的特定主形状?
到目前为止,我正在尝试这个
Private Sub CommandButton1_Click()
Dim shp As Visio.Shape
Dim page As Visio.page
Set page = Application.ActiveWindow.page
Set shp = Application.Documents.Item("shapes.vssx").Masters.ItemU("ressource")
page.Drop shp, 1, 1
End Sub
它返回类型不匹配。我错过了什么?
解决方案
您希望删除 aMaster
而不是 a Shape
,因此请尝试对您的代码进行此修改(未经测试):
Private Sub CommandButton1_Click()
Dim mst as Visio.Master
Dim shp As Visio.Shape
Dim pag As Visio.page
Set pag = Application.ActiveWindow.Page
Set mst = Application.Documents.Item("shapes.vssx").Masters.ItemU("ressource")
'You might also want to add some checks that the target document and then master exist
Set shp = pag.Drop(mst, 1, 1)
End Sub
推荐阅读
- alexa - Alexa 接受内置插槽类型的错误值
- mysql - 从外部表中按日期和 id 对 COUNT 进行分组
- r - 返回字符串的开头,最多包含两个字符中的任何一个
- azure - 使用 Azure Data Lake gen2 列出 blob 的问题
- python - 当 python 在 SQL Server 代理中作为作业运行时出现 ModuleNotFoundError
- scala - 如何创建宏以在案例类中创建 val 列表?
- primefaces - 如何制作可关闭的 p:selectOneButton?
- xml - XSLT 中子字符串的复杂使用
- r - Rcpp:将本机 C++ 函数作为参数传递?
- c# - SignalR Clients.Client($id) 无效