0

如果我设置了一个子程序以便可以从客户功能区按钮调用它,是否仍然可以从其他子程序调用这些子程序?我收到的参数不是可选的错误消息,但我不确定要传递给子程序的参数是什么,因为我不是从功能区按钮而是从另一个子程序本身内部调用的。

Sub Reset(ByVal Control As IRibbonControl)
    Call ResetForumlas
    Call ResetValues
End Sub

Sub ResetForumlas(ByVal Control As IRibbonControl)
    "Do some stuff"
End Sub

Sub ResetValues(ByVal Control As IRibbonControl)
    "Do Some more stuff"
End Sub

谢谢您的帮助。

4

4 回答 4

1

这是一个旧帖子,但如果有人到达这里......试试这个:

Sub Reset(ByVal Control As IRibbonControl)
    Call ResetForumlas
    Call ResetValues
End Sub

sub test
    dim ribboncontrol as IRibbonControl
    call Reset (ribboncontrol)
end sub
于 2019-09-26T17:55:10.157 回答
0

在这种情况下,将参数作为可选变量传递非常有用:

Sub Reset(Optional ByVal Control As IRibbonControl)
    ResetForumlas
    ResetValues
End Sub

Sub ResetForumlas(Optional ByVal Control As IRibbonControl)
    "Do some stuff"
End Sub

Sub ResetValues(Optional ByVal Control As IRibbonControl)
    "Do Some more stuff"
End Sub
于 2014-09-03T01:12:00.727 回答
0

请在没有电话的情况下试一试。像这样

Sub Reset(ByVal Control As IRibbonControl)
    ResetForumlas
    ResetValues
End Sub

Sub ResetForumlas(ByVal Control As IRibbonControl)
    "Do some stuff"
End Sub

Sub ResetValues(ByVal Control As IRibbonControl)
    "Do Some more stuff"
End Sub
于 2014-09-03T00:25:37.763 回答
0

我总是在功能区调用的 subs 中添加一个 _onAction 后缀 - 以相应地识别它们

然后可以用描述他们正在做什么的名称来调用正在做这项工作的 Subs。

Sub ResetAll_onAction(ByVal Control As IRibbonControl)
    ResetForumlas
    ResetValues
End Sub

Sub ResetFormulas_onAction(ByVal Control As IRibbonControl)
    resetFormulas
End Sub

Sub ResetValues_onAction(ByVal Control As IRibbonControl)
    resetValues
End Sub

Public Sub resetFormulas()
   'Do some stuff
End Sub

Public Sub resetValues()
   'Do other stuff
End Sub
于 2021-11-15T19:14:00.717 回答