floating toolbar in excel

G

Gaurav

Hi,

When my application opens an Excel sheet, it adds one floating toolbar
with few buttons on it.
Use can close this floating toolbar directly from the excel sheet.

There can be a situation where an excel is allready opened. Now i am
getting an exception when i try to add a toolbar which is already
there. How can i find out whether i had already added the toolbar or
not.

Thanks
Gaurav
 
S

Steve Rindsberg

Hi,

When my application opens an Excel sheet, it adds one floating toolbar
with few buttons on it.
Use can close this floating toolbar directly from the excel sheet.

There can be a situation where an excel is allready opened. Now i am
getting an exception when i try to add a toolbar which is already
there. How can i find out whether i had already added the toolbar or
not.

Trap the error that occurs when you try to add a toolbar that exists

or

Iterate through the commandbars collection looking for a toolbar with the name
you plan to give YOUR tool bar:

Sub Test()
Dim x As Long

With Application
For x = 1 To Application.CommandBars.Count
Debug.Print .CommandBars(x).Name
Next
End With
End Sub
 
D

Dale Fye

You could also trap for an error using the Commandbars.FindControl method. I
usually set the Tag property of each of the elements of my commandbars so
that I can use that to search by.

IF commandbars.FindControl(Tag:="something") IS NOTHING THEN
Call CreateMenu
ENDIF

HTH
Dale
 

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