Attaching a toolbar to a workbook

  • Thread starter Thread starter Prixton
  • Start date Start date
P

Prixton

Hi,
I have a workbook with macros. Now I want a toolbar that appears only when I
open that specific workbook and disappears when I close the workbook. I can
not make this work as I want so if someone can help me, I´d be very happy. I
am running Excel 2003.
 
Try something like the following. Put all the code shown below in the
ThisWorkbook code module. Change "MyToolBar" to the name of your command bar
name.

Private Sub Workbook_Activate()
Application.CommandBars("MyToolBar").Visible = True
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.CommandBars("MyToolBar").Delete
End Sub

Private Sub Workbook_Deactivate()
Application.CommandBars("MyToolBar").Visible = False
End Sub

Private Sub Workbook_Open()
Application.CommandBars("MyToolBar").Visible = True
End Sub


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

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