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-
Leith Ross - 18 Sep 2007 03:39 GMT
On Sep 17, 6:18 pm, "Farrar > Tweety" <toxicdistort...@hotmail.com>
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
Doug Glancy - 18 Sep 2007 04:09 GMT
Farrar>Tweety,
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
> 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 - 18 Sep 2007 04:14 GMT
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
> 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-

Signature
Dave Peterson