I have a macro enabled (.docm) Word 2007 document that I’m using to develop a Word Add in.
The VBA in the Word document uses an Auto Open macro to install a Control Bar (menu) in the Add-Ins group. This is what the code looks like:
Set cbcNewMenu = cbMenuBar.Controls.Add _
(msoControlPopup, , , idHelp)
cbcNewMenu.Caption = p_sMenuName
With cbcNewMenu.Controls.Add(Type:=msoControlButton)
.Caption = "ConvertTable"
.OnAction = "mod100Procs.UpdateTable"
End With
The macro is in a separate module named mod100Procs and is declared like this:
Public Sub UpdateTable()
.
.
.
End Sub
The program installs the menu and the menu item: “Convert Table” works if the active document is the .docm document where the VBA code lives. When I try to access the menu while another document is active I get and error message the macro cannot be found.
I tried changing the .OnAction to read like this:
.OnAction = “’” & ThisDocument.Name & "’!mod100Procs.UpdateTable"
To fully qualify it but that doesn’t work.
I don’t have this problem in Excel. What am I missing?