I need some help with a shortcut menu that is being created via VBA. I want it to run a function within an open form, but for some reason can't get it to work.
Here is the test code that I have written within a module to create the shortcut menu:
Public Function SCTest()
Dim cmbShortcutMenu As office.CommandBar
Dim ctlCBarControl As CommandBarControl
Set cmbShortcutMenu = CommandBars.Add("Shortcut_Test", msoBarPopup, False, False)
'Show selected outcomes
Set ctlCBarControl = cmbShortcutMenu.Controls.Add(msoControlButton)
.Caption = "Test"
.OnAction = "=forms!frmSCTest.SC_Function()"
.Tag = .Caption
Set cmbShortcutMenu = Nothing
Within the form "SCTest", I have created the following function
Public function SC_Function()
I have added a Textbox, set the shortcut menu property and when I right-click, select "Test" I'd like it to trigger SC_Function() - but it doesn't. I'm guessing I have something wrong with the .onaction syntax, but haven't been able to solve it.
Any ideas what I'm doing wrong?