VB Macro Buttons

  • Thread starter Thread starter Keda Wang
  • Start date Start date
K

Keda Wang

Hello,

I have successfully created macros on the Menu Bar,
however the buttons stay resident for all excel files. I
know it is possible to create the macro buttons to only be
loaded when the appropriate file is opened. The buttons
should disappear when the file is closed.

Does anyone know how to do this? If so, please share.
Thanks!
 
Keda,

You're looking for the Temporary parameter, which prevents Excel being stuck
with it.

You can have the Auto_Close procedure destroy the toolbar too.

Const cCommandBar = "MyCommandBar"
Dim bar As CommandBar
For Each bar In Application.CommandBars
If bar.Name = cCommandBar Then bar.Delete
Next

I have an example for Commandbars here:
http://www.vangelder.co.nz/excel/index.html

Rob
 
Back
Top