View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default Access to user-created menu

Otto,

Do the menu items have a Tag property set? If so, you can use code in
ThisWorkbook like the following, where C_TAG is the tag associated with
either all the menu items or the top-level menu item.


Private Sub Workbook_Activate()
'''''''''''''''''''''''''''''''''''''
' Make the controls visible for this
' workbook.
'''''''''''''''''''''''''''''''''''''
Dim Ctrl As Office.CommandBarControl
On Error Resume Next
For Each Ctrl In Application.CommandBars.FindControls(Tag:=C_TAG)
Ctrl.Visible = True
' OR
Ctrl.Enabled = True
Next Ctrl

End Sub

Private Sub Workbook_Deactivate()
'''''''''''''''''''''''''''''''''''''''
' Hide the controls for other workboks.
'''''''''''''''''''''''''''''''''''''''
Dim Ctrl As Office.CommandBarControl
On Error Resume Next
For Each Ctrl In Application.CommandBars.FindControls(Tag:=C_TAG)
Ctrl.Visible = False
' OR
Ctrl.Enabled = False
Next Ctrl

End Sub

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)





"Otto Moehrbach" wrote in message
...
Excel XP & Win XP
I have a user created menu that I built with John Walkenbach's easy
menu maker. The menu has about 30 items. Of course, the menu is
available to any open workbook besides the also-open intended workbook.
I know how to place code in each macro for each menu item to check the
active workbook name. My question is this: Can I prevent access or pop
up a MsgBox (and cancel) when the primary menu item is accessed with the
wrong workbook active, rather than do the same thing for each of the 30
menu item macros? Thanks for your time. Otto