Assign macro to WB-specific toolbar button?

I

Ian

In Excel 2000, s it possible to assign a macro to a toolbar button and make
that toolbar button visible (or active) ONLY when the book containing the
macro is active?

I've written a macro and assigned it to a toolbar button, but the button is
always visible and active.
 
B

Bob Phillips

Private Sub Workbook_Activate()
Application.CommandBars("CB name").Controls("button name").Visible =
True
End Sub

Private Sub Workbook_Deactivate()
Application.CommandBars("CB name").Controls("button name").Visible =
False
End Sub

This is ThisWorkbook code module code.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
I

Ian

Thanks, Bob. This hides the button perfectly. It is the only button on a
custom toolbar. Is it possible to also hide the toolbar, such that it
reappears docked in the same place it was?
 
B

Bob Phillips

Just take out the control

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

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


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
B

Bob Phillips

Always works better with no control <bg>

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
I

Ian

I think I'm losing it <vbg>

--
Ian
--
Bob Phillips said:
Always works better with no control <bg>

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)
 

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

Top