Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MenuBar Control not finding Macro

Status
Not open for further replies.

Rofeu

Technical User
Apr 13, 2005
500
NL
Hello,

I've this file that programmatically creates a dropdown on the main menubar with a list of controls on it.

Now, I'm setting the OnAction to macro's listed in a module.

If I call this module Menu_Options and set the controls to run the macro's everything works fine, however if I change the module name to C1_Menu_Options and change the name accordingly in setting the controls, it tells me it can't find the macro.

Does anybody have an idea why this might be?

Code:
Dim My_Menu As Object

Sub CreateCustomMenu()

Call RemoveCustomMenu

Set My_Menu = Application.CommandBars(1).Controls.Add(Type:=10, temporary:=False)
My_Menu.Caption = cMenuName

Call CreateMenuItem(cMenuName, "D4_Menu_Options.C1A", "C1A")
Call CreateMenuItem(cMenuName, "D4_Menu_Options.C1B", "C1B")
Call CreateMenuItem(cMenuName, "D4_Menu_Options.C1C", "C1C")
Call CreateMenuItem(cMenuName, "D4_Journal_Validation.D4A", "D4A") '<-- This does work, by the way!
Call CreateMenuItem(cMenuName, "D4_Menu_Options.C1E", "C1E")
Call CreateMenuItem(cMenuName, "D4_Menu_Options.C1F", "C1F")

Set My_Menu = Nothing

End Sub


Sub CreateMenuItem(Menu As String, Macro As String, Optional Caption As String)

If Caption = vbNullString Then Caption = Macro
If InStr(1, Caption, "&") = 0 Then Caption = "&" & Caption

Dim My_SubMenu As Object
Set My_SubMenu = Application.CommandBars(1).Controls(Menu).Controls.Add(Type:=1, temporary:=False)
With My_SubMenu
    .Caption = Caption
    .OnAction = Macro
End With

Set My_SubMenu = Nothing

End Sub

Cheers,

Roel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top