View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
Mary Mary is offline
external usenet poster
 
Posts: 190
Default Macros and Menu Command

I also found something else on the web that may be a help:

Custom menu items are going to be available to all Workbooks and Worksheets.
This can be an issue when the macro is intended for a specific Worksheet in a
specific Workbook. All you need to know to overcome this problem is the name
of the Toolbar you have placed your custom menu item on. The Worksheet Menu
Bar is a safe bet.

Activate the sheet that your macro needs active to run correctly.
Right click on the sheet name tab and select View Code and place in the code
as shown below:
Private Sub Worksheet_Activate()
Application.CommandBars("Worksheet Menu Bar").Controls _
("My Macro").Enabled = True
End Sub

Private Sub Worksheet_Deactivate()
Application.CommandBars("Worksheet Menu Bar").Controls _
("My Macro").Enabled = False
End Sub


Simply change the name of My Macro to the name of your menu item.


"bj" wrote:

record a macro to add and one to delete the menu item
in the workbook you want it on put the install in on startup and the delete
on close

"mary" wrote:

I recorded a simple macro and saved it only in a specific workbook. I placed
a menu command on that toolbar.

Now every workbook I open has the menu command in it and when I click the
menu command that appears in a workbook where it shouldn't, it automatically
opens up the worksheet that the macro was originally designed for.

How can I save the recorded macro and menu command only in one workbook and
be sure that it doesn't appear anywhere else?