Thread: delete toolbar
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
drhalter drhalter is offline
external usenet poster
 
Posts: 39
Default delete toolbar

That's great. I posted just prior to yours, I happened to think of how to do
it about 2 seconds after I posted the original question. But, any ideas on
how to test whether the toolbar exists? I have the following code in a
workbook_sheetcalculate event:

If application.commandbars("myBar").visible = true then

but I get an error when myBar doesn't exist. The code works great when the
toolbar does exist.

Thanks
Dave

"Jan Karel Pieterse" wrote:

Hi Drhalter,

So, if the toolbar exists, I would like it to be visible, if it is
not visible or made not visible, I don't want it to continue to exist. Any
ideas?



This gives you an idea how to create a bar that cannot be closed:

Sub createbar()
Dim oBar As CommandBar
removebar
Set oBar = CommandBars.Add
oBar.Name = "Test"
oBar.Protection = msoBarNoChangeVisible
oBar.Visible = True
End Sub

Sub removebar()
On Error Resume Next
Application.CommandBars("Test").Delete
End Sub

Regards,

Jan Karel Pieterse
Excel MVP
http://www.jkp-ads.com