Run a macro when document is closed! Help!!


Posted by Flavio Filho on January 09, 2002 6:52 AM

Hi!
I made a couple of Macros and a Toolbar to hold them all.
I called this toolbar 'barra record'.
Its loading OK, but when the document is closed the toolbar remais in Excel which is not good... And there is other problems like when you open the file in another location it will not work *the toolbar*!

I tried a Auto_Open macro:
Public Sub Auto_Open()
Application.CommandBars("barra record").Delete
End Sub

The problem is this macro deletes the old toolbar and dosnt load it!! I´d like the opposite....
To run this macro when this document is closed and not opened...
How i do that???
Thanks!



Posted by Scott on January 09, 2002 7:24 AM

Have you tried:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.CommandBars("barra record").Delete
End Sub

This must be in the "ThisWorkbook" project.