Excel and Office RAQ

Checking for the existence of a given toolbar

   

Tactical solutions

Research projects

Microsoft Office

Multiple choice guessing

Services

Knowledge measurement audit

Item bank services

Item design course

Products

WaterMarker

iOTA

STASiS

ACiS

CaSelector

CaSCADE

Technical articles

Excel and Office RAQ

Free Excel Add-in

Free PowerPoint Add-in

Contact

Home page

Q: Can someone explain to me how I would go about doing something such as this, the EXISTS method does not exist for commandbars?

If Not Application.CommandBars("Reports").Exists Then

  Call Make_Toolbars

Else

  CommandBars("Reports").Visible = True

End If

A: Use this line of code just before your line which makes it visible:

  On Error Goto MakeToolbar

That way it will make it visible if it exists, or fly off to the MakeToolbar part if it doesn't. (If this subroutine goes on to do other things beyond checking for the toolbar's existence, you might want to consider resetting the error checking once past this point.) At the end of your subroutine, add the following lines:

  Exit sub

  MakeToolbar:

    Call Make_Toolbars 

 

Back to other RAQ topics