我有一些自定义快捷菜单可以调用某些功能。在过去,我总是使用不接受任何输入的功能,但我试图在这些功能上使用输入并且它似乎并不喜欢它。这是代码:
Sub fRunDataGraphC2Flow()
Dim cmbshortcutmenu As Office.CommandBar
Dim cmbControl As Office.CommandBarControl
Set cmbshortcutmenu = CommandBars.Add("fRunDataGraphC2Flow", msoBarPopup, False, False)
'Copy Command
cmbshortcutmenu.Controls.Add Type:=msoControlButton, Id:=19
'Adjust Axes
'function = AdjustAxis("C2Flow")
Set cmbControl = cmbshortcutmenu.Controls.Add(msoControlButton)
With cmbControl
.Caption = "Adjust Axis"
.Style = msoButtonIconAndCaption
.OnAction = "AdjustAxis(""C2Flow"")"
.FaceId = 625
.BeginGroup = True
End With
...
当我尝试使用命令" Adjust Axis"我收到以下错误:
Microsoft Access无法运行宏或回调函数' AdjustAxis(" C2flow")'确保宏或函数存在并采用正确的参数。该函数旨在获取字符串。所以它应该接受这个,但我想知道引号是否令人困惑。
任何人都有这方面的经验吗?
答案 0 :(得分:0)
尝试
.OnAction = "'AdjustAxis ""C2Flow""'"
示例:
Sub y()
Dim CBar As CommandBar
Dim Ctl As CommandBarControl
Set CBar = CommandBars("Cell")
Set Ctl = CBar.Controls.Add(msoControlButton, 19)
With Ctl
.Caption = "X"
.OnAction = "'x ""Hello World!""'"
End With
End Sub
Sub x(s As String)
MsgBox s
End Sub