Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Testing if Commandbar exists
Can't seem to get a handle on this. How would I test, in VBA, if the
toolbar "My Tools" exists? Any help appreciated, in the meantime I'm going to keep hammering away. -gk- |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Testing if Commandbar exists
On Sep 17, 6:18 pm, "Farrar Tweety"
wrote: Can't seem to get a handle on this. How would I test, in VBA, if the toolbar "My Tools" exists? Any help appreciated, in the meantime I'm going to keep hammering away. -gk- Hello, Here is a code example... Dim CmdBar As CommandBar Dim Exists As Boolean For Each CmdBar In Application.CommandBars If CmdBar.Name = "My Tools" Then Exists = True Exit Loop End If Next CmdBar Sincerely, Leith Ross |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Testing if Commandbar exists
FarrarTweety,
Here's a function to test it: Function CommandbarExists(CommandBarName) As Boolean Dim cbar As CommandBar On Error Resume Next Set cbar = Application.CommandBars(CommandBarName) If Err.Description = "" Then CommandbarExists = True End If End Function Run the test sub below and you should get "True" and then "False" in the immediate window, unless you have a commandbar called "Foo": Sub test() Debug.Print CommandbarExists("Standard") Debug.Print CommandbarExists("Foo") End Sub hth, Doug "Farrar Tweety" wrote in message ... Can't seem to get a handle on this. How would I test, in VBA, if the toolbar "My Tools" exists? Any help appreciated, in the meantime I'm going to keep hammering away. -gk- |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Testing if Commandbar exists
dim myCmdBar as CommandBar
set mycmdbar = nothing on error resume next set mycmdbar = application.commandbars("my tools") on error goto 0 if mycmdbar is nothing then 'doesn't exist else 'yep, it exists end if "Farrar Tweety" wrote: Can't seem to get a handle on this. How would I test, in VBA, if the toolbar "My Tools" exists? Any help appreciated, in the meantime I'm going to keep hammering away. -gk- -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Tag in CommandBar | Excel Programming | |||
cant dim as commandbar | Excel Programming | |||
CommandBar | Excel Programming | |||
Testing to see if a Workbook menu item exists | Excel Programming | |||
Testing to see if a sheet name exists | Excel Programming |