Assign a Custom Toolbar to only one WorkBook

  • Thread starter Thread starter Ken Soenen
  • Start date Start date
K

Ken Soenen

Need Help:
I am trying to assign a custom toolbar to only one
workbook. The custom toolbar consists of several buttons each of which has a
macros assigned. The macros are such that they only can be used in the one
workbook. I CAN get the toolbar assigned to the workbook I want, but, the
problem is that the toolbar is also assigned to every other existing
workbook???


Any thoughts would be appreciated,
ken
 
One way:

After attaching the toolbar to your workbook. Put these macros in your
ThisWorkbook code module:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error Resume Next
Application.CommandBars("Custom 1").Delete
On Error GoTo 0
End Sub

Private Sub Workbook_Activate()
On Error Resume Next
With Application.CommandBars("Custom 1")
.Enabled = True
.Visible = True
End With
On Error GoTo 0
End Sub

Private Sub Workbook_Deactivate()
On Error Resume Next
With Application.CommandBars("Custom 1")
.Enabled = False
.Visible = False
End With
On Error GoTo 0
End Sub
 
That article doesn't seem to have very much to do with the OP's
question. It's an article about how to add a menu item to the menu bar.
Once the item is added, it's available to all open workbooks.

The OP asked about configuring a custom toolbar so that it was only
available to a single workbook.

There's absolutely no need for the toolbar to be built using VBA. While
I tend to build my toolbars that way, there are some disadvantages to
doing so.
 

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