Make toolbar buttons appear only in specific files?

  • Thread starter Thread starter Christiane
  • Start date Start date
C

Christiane

I have created macros in a workbook and I have assigned those macros t
toolbar buttons.

How can I have the buttons appear only when I open that specifi
workbook?

I created a menu too, how can I have this menu appear only in tha
workbook as well?

Thank you.
CHristian
 
something like

Private Sub Workbook_Open()

With Application.CommandBars
.Controls("Formatting").Controls("myButton").Visible = True
.Controls("Tools").Controls("myMenu").Visible = True
End With

End Sub

Private Sub Workbook_Before(Cancel As Boolean)

With Application.CommandBars
.Controls("Formatting").Controls("myButton").Visible = False
.Controls("Tools").Controls("myMenu").Visible = False
End With

End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Sorry Chrstiane, my error

Private Sub Workbook_Open()

With Application.CommandBars("Formatting")
.Controls("myButton").Visible = True
End With
With Application.CommandBars("Worksheet Menu Bar")
.Controls("Tools").Controls("myMenu").Visible = True
End With

End Sub

Private Sub Workbook_Before(Cancel As Boolean)

With Application.CommandBars("Formatting")
.Controls("myButton").Visible = False
End With
With Application.CommandBars("Worksheet Menu Bar")
.Controls("Tools").Controls("myMenu").Visible = False
End With

End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Christiane,

The Formatting is the name of the toolbar to put the button on, and MyButton
is just a handle to hang onto the button, for id purposes.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top