Delete toolbar if it exists


Posted by Flavio on January 10, 2002 8:51 AM

Hi!
I made a macro that deletes a toolbar if it exists after the document is closed... I did that because I made a custom toolbar called RECORD and it´s only used by ONE spreadsheet...
This is the code I have:
Sub Auto_Close()
Application.CommandBars("barra record").Delete
End Sub

I would like a IF stament like IF "barra record" exists, THEN delete it!
How I do that???



Posted by Juan Pablo G. on January 10, 2002 9:15 AM

One easier method i use:

On Error Resume Next
Application.CommandBars("barra record").Delete
On Error Goto 0

That way, it will delete it if exists and won't if it doesn't

Juan Pablo G.