我正在创建一个宏以将菜单按钮添加到选定的 Visio 形状对象,因此每当用户右键单击该框时,都会出现一个选项并调用宏。我为对象创建了几个属性,将由要调用的操作使用。
我可以通过使用ShapeSheet编辑器 -> 查看部分 -> 操作 -> 并使用 Action 值配置操作
来手动完成(成功)=CALLTHIS("ThisDocument.myFunction",,Prop.IPAddress)
sub myFunction (shpObj as Visio.shape, strIPAddress as String)
'working code with the functionsI want it to do. here I use the strIPAddress passed as an argument
我正在尝试做的是通过创建一个执行相同操作的宏来自动执行此操作:
Public Sub AddActionToShape()
Dim vsoShape1 As Visio.Shape
Dim intActionRow As Integer
'Performs this action to the selected item
Set vsoShape1 = Application.ActiveWindow.Selection(1)
'create row in the action section (http://office.microsoft.com/en-gb/visio-help/HV080902125.aspx)
intActionRow = vsoShape1.AddRow(visSectionAction, visRowLast, visTagDefault)
'add action to the row (http://msdn.microsoft.com/en-us/library/office/ff765539(v=office.15).aspx)
'HERE IS THE PROBLEM
**vsoShape1.CellsSRC(visSectionAction, intActionRow, visActionAction).FormulaU = """myFunction(vsoShape1, vsoShape1.Prop.IPAddress)"""**
vsoShape1.CellsSRC(visSectionAction, intActionRow, visActionMenu).FormulaU = """My Function"""
End Sub
我的问题:
在传递参数时,我应该在FormulaU上设置什么值来引用宏中定义的子例程。如果我不应该使用这个 FormulaU 属性,请指出正确的属性。