Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vba 以编程方式将菜单操作添加到Visio_Vba_Visio_Shapesheet - Fatal编程技术网

Vba 以编程方式将菜单操作添加到Visio

Vba 以编程方式将菜单操作添加到Visio,vba,visio,shapesheet,Vba,Visio,Shapesheet,我正在创建一个宏,用于将菜单按钮添加到选定的Visio shape对象,因此每当用户右键单击该框时,将显示一个选项并调用宏。我为对象创建了几个属性,将由要调用的操作使用 我可以使用ShapeSheet编辑器->查看部分->操作->并使用操作值配置操作,手动(成功地) =CALLTHIS(“ThisDocument.myFunction”、Prop.IPAddress) 我试图通过创建一个宏来自动执行此操作,该宏执行相同的操作: Public Sub AddActionToShape()

我正在创建一个宏,用于将菜单按钮添加到选定的Visio shape对象,因此每当用户右键单击该框时,将显示一个选项并调用宏。我为对象创建了几个属性,将由要调用的操作使用

我可以使用ShapeSheet编辑器->查看部分->操作->并使用操作值配置操作,手动(成功地
=CALLTHIS(“ThisDocument.myFunction”、Prop.IPAddress)

我试图通过创建一个宏来自动执行此操作,该宏执行相同的操作:

    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完全设置为手动设置的内容。就是

CALLTHIS("ThisDocument.myFunction",,Prop.IPAddress)
尝试:


最后我就这样做了,效果很好

Dim formula As String
formula = "=CALLTHIS([MODULE],,[ARG1],[ARG2])"
formula = Replace(formula, "[MODULE]", Chr(34) & "ThisDocument.myFunction" & Chr(34))
formula = Replace(formula, "[ARG1]", "Prop.IPAddress")
formula = Replace(formula, "[ARG2]", "Prop.Username")

'After the formula has been created, apply it to the row
shape.CellsSRC(visSectionAction, rowBeingEdited, visActionAction).formula = formula

我已经在addin(在visualstudio中)中添加了这段代码,当我单击上下文菜单选项时,不会调用该方法。你能帮忙吗?
vsoShape1.CellsSRC(visSectionAction, intActionRow, visActionMenu).FormulaU = _
    "CALLTHIS(""ThisDocument.myFunction"",,Prop.IPAddress)"
Dim formula As String
formula = "=CALLTHIS([MODULE],,[ARG1],[ARG2])"
formula = Replace(formula, "[MODULE]", Chr(34) & "ThisDocument.myFunction" & Chr(34))
formula = Replace(formula, "[ARG1]", "Prop.IPAddress")
formula = Replace(formula, "[ARG2]", "Prop.Username")

'After the formula has been created, apply it to the row
shape.CellsSRC(visSectionAction, rowBeingEdited, visActionAction).formula = formula