ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Toolbars that only show up for a given worksheet. (https://www.excelbanter.com/excel-discussion-misc-queries/197451-toolbars-only-show-up-given-worksheet.html)

livetohike

Toolbars that only show up for a given worksheet.
 
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

Dave Peterson

Toolbars that only show up for a given worksheet.
 
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.

livetohike wrote:

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


--

Dave Peterson


All times are GMT +1. The time now is 10:33 AM.

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