Does a toolbar exist?

S

Shane

I'm trying to write code that will look in the organizer to see if a toolbar
exists. I tried this:
If exists (Organizer Type:=6, FileName:="Global (+ cached Enterprise)",
Name:="APM") then
but I'm getting an error.
Any suggestions?
 
R

Rod Gill

Try:

Dim MyBar As CommandBar
On Error Resume Next
Set MyBar = CommandBars("My Macros")
If MyBar Is Nothing Then
Set MyBar = CommandBars.Add(Name:="My Macros",
Position:=msoBarFloating, Temporary:=True)
MyBar.Visible = True
End If

This code attempts to set a CommandBar variable to point to a toolbar. If
the action fails, MyBar variable is still=Nothing. If so this code creates
the toolbar.
 
S

Shane

Rod, it worked great. You're the man.

Rod Gill said:
Try:

Dim MyBar As CommandBar
On Error Resume Next
Set MyBar = CommandBars("My Macros")
If MyBar Is Nothing Then
Set MyBar = CommandBars.Add(Name:="My Macros",
Position:=msoBarFloating, Temporary:=True)
MyBar.Visible = True
End If

This code attempts to set a CommandBar variable to point to a toolbar. If
the action fails, MyBar variable is still=Nothing. If so this code creates
the toolbar.
--

Rod Gill
Project MVP
Visit www.msproject-systems.com for Project Companion Tools and more
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top