ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Make toolbar buttons appear only in specific files? (https://www.excelbanter.com/excel-programming/295837-make-toolbar-buttons-appear-only-specific-files.html)

Christiane[_9_]

Make toolbar buttons appear only in specific files?
 
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

--
Message posted from http://www.ExcelForum.com


Bob Phillips[_6_]

Make toolbar buttons appear only in specific files?
 
something like

Private Sub Workbook_Open()

With Application.CommandBars
.Controls("Formatting").Controls("myButton").Visib le = 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").Visib le = 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)

"Christiane " wrote in message
...
I have created macros in a workbook and I have assigned those macros to
toolbar buttons.

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

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

Thank you.
CHristiane


---
Message posted from http://www.ExcelForum.com/




Christiane[_10_]

Make toolbar buttons appear only in specific files?
 
It doesn't recognize
.controls

?

--
Message posted from http://www.ExcelForum.com


Bob Phillips[_6_]

Make toolbar buttons appear only in specific files?
 
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 " wrote in message
...
It doesn't recognize
controls

??


---
Message posted from http://www.ExcelForum.com/




Christiane[_11_]

Make toolbar buttons appear only in specific files?
 
What do I put where it says formatting and mybutton

--
Message posted from http://www.ExcelForum.com


Bob Phillips[_6_]

Make toolbar buttons appear only in specific files?
 
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)

"Christiane " wrote in message
...
What do I put where it says formatting and mybutton?


---
Message posted from http://www.ExcelForum.com/





All times are GMT +1. The time now is 11:30 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com