Toolbars that only show up for a given worksheet.

L

livetohike

I keep macros specific to a given worksheet inside the worksheet (not
in PERSONAL.XLS.

I like to associate those macros to toolbar buttons. So far my
toolbars end up globa (all workbooks can see them, even when the
toolbar (and its associated functions) has nothing to do w/ the
particular worksheet.

How can I associate toolbars (along w/ its assigned macros) to a
specific workbook.

Thanks
 
D

Dave Peterson

You could take the easy way out and have each of the subs in your workbook check
to see if the activeworkbook is one that should be able to run the code.

if thisworkbook.name <> activeworkbook.name then
msgbox "Nope"
exit sub
end if

at the top of each of your subs.

========
Another option would be to destroy the toolbar each time you deactivate the
workbook and recreate it each time you activate the workbook.

You'd use the workbook_activate event and the workbook_deactivate event.

I would think that the code would look very similar to the code you use in the
workbook_Open and workbook_beforeclose (or auto_open and auto_close) events.
 

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