Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Where do i add the toolbar code 1

Status
Not open for further replies.

Thwarted

Technical User
Oct 10, 2002
32
CA
Hi
I posted this on the wrong forum but Skip was kind enough to help me out - the only thing is - where do i put the code for adding and removing the toolbar

OnOpen and OnClose ?? (do those exist)?

Thank you!!


(original post and answer below)

Hi

Is there a way to add a toolbar to a workbook that will be shared? I am creating a template and want the toolbar to stick with the workbook every time it is saved as a new file.

I addd the toolbar and it works great on my hard drive and as long as i dont rename the file.

Any advice would be much appreciated.

Thank you!!

-----------------------------------------


Hi,

Toolbars (CommandBars) are not workbook objects, rather application objects. So they are associated with your Excel Application, and not an specific workbook you might save.

So here's what you would need to do. When this workbook opens, have the toolbar(s) ADDED and when the workbook closes, have the toolbar(s) DELETED.

Turn on your macro recorder and have at it. To get help for customizing these macros to your situation, please post your questions in forum707: VBA Visual Basic for Applications (Microsoft).
Skip,
Don't let the Diatribe...
talk you to death!
Just traded in my old subtlety...
for a NUANCE!


 
In the ThisWorkbook module you may use the Workbook_Open and the Workbook_BeforeClose event procedures.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Actually, you can attach a custom toolbar to a spreadhsheet if that is what you want and then use the event procedures mentioned earlier to display or hide them. Go to the Customize menu of the toolbar (Not Excel 2007). On the toolbars tab, select the toolbar name and then click on the Attach button. you can then attach the toolbar to the spreadsheet or template.
 
Hi Judy

Thank you - that does work! I think now i will just have to put something in BeforeClose so that it will remove the toolbar from the application (so it is not showing up on other workbooks). Hoping it will stick to the workbook though after i do that!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top