S
Seeb
Hi everybody,
I'd like to know if there's a way to check if a temporary Toolbar is present
before deleting it. I have a document that must create a toolbar on the
DocumentOpened event and deletes it on the BeforeDocumentClose Event. I
tried this:
Sub DeleteDrawingCommandBar()
Dim cbars As Office.CommandBars
Dim cbar1 As Office.CommandBar
On Error Resume Next
Set cbars = Application.CommandBars
If (cbars("MyToolbar").Enabled = True) Then 'BUG HERE
Set cbar1 = cbars("MyToolbar")
cbar1.Delete
End If
end sub
But it fails at the line 'BUG HERE if MyToolbar doesn't exist. Is there a
way to check if the toolbar is present before deleting it, and in the same
way checking if it exists before creating it?
Thanks a lot,
Seeb
I'd like to know if there's a way to check if a temporary Toolbar is present
before deleting it. I have a document that must create a toolbar on the
DocumentOpened event and deletes it on the BeforeDocumentClose Event. I
tried this:
Sub DeleteDrawingCommandBar()
Dim cbars As Office.CommandBars
Dim cbar1 As Office.CommandBar
On Error Resume Next
Set cbars = Application.CommandBars
If (cbars("MyToolbar").Enabled = True) Then 'BUG HERE
Set cbar1 = cbars("MyToolbar")
cbar1.Delete
End If
end sub
But it fails at the line 'BUG HERE if MyToolbar doesn't exist. Is there a
way to check if the toolbar is present before deleting it, and in the same
way checking if it exists before creating it?
Thanks a lot,
Seeb