Hi thanks for the above, no I don't have code that opens or activates other workbooks. I tried the above code in a new workbook to see what it looks like when activated, upon selecting Create Menu, I got a VBA message which read "Compile error: Variable not defined" with that it had (MenuObject =) high lighted just next to the set function, can you please review and advise. Thanks again.
Sub CreateMenu()
Call DeleteMenu ' Make sure the menu is not already there
Set MenuObject = Application.CommandBars(1).Controls.Add(Type:=msoControlPopup, _
Before:=9, Temporary:=True)
MenuObject.Caption = "Menu 1"
Call AddMenuItem("M1 Item 1", "Item11Subroutine")
Call AddMenuItem("M1 Item 2", "Item12Subroutine")
Call AddMenuItem("M1 Item 3", "Item13Subroutine")
Set MenuObject = Application.CommandBars(1).Controls.Add(Type:=msoControlPopup, _
Before:=9, Temporary:=True)
MenuObject.Caption = "Menu 2"
Call AddMenuItem("M2 Item 1", "Item21Subroutine")
Call AddMenuItem("M2 Item 2", "Item22Subroutine")
End Sub
Bookmarks