Never tried, but it'll be similar to other collections presumably. E.g.
> Application.CommandBars("Freddie").Controls.Add
tells me that there is a CommandBars collection. A couple of ways to go
about these things ...
- you can scan the collection and look at the names to see if you find the
one you want
- you can put "on error resume next" / "on error goto 0" statements around a
statement that Sets a variable equal to the particular command bar. If the
variable ends up with nothing in it, then it doesn't exist. E.g. (just had
a play):
Option Explicit
Private Sub CommandButton1_Click()
Dim FreddieBar As CommandBar: Set FreddieBar = Nothing
On Error Resume Next
Set FreddieBar = Application.CommandBars("Freddie")
On Error GoTo 0
If FreddieBar Is Nothing Then
Call MsgBox("doesn't exist")
Else
Call MsgBox("does exist")
Application.CommandBars("Freddie").Delete
End If
Application.CommandBars.Add(Name:="Freddie").Visible = True
Set FreddieBar = Nothing
On Error Resume Next
Set FreddieBar = Application.CommandBars("Freddie")
On Error GoTo 0
If FreddieBar Is Nothing Then
Call MsgBox("doesn't exist")
Else
Call MsgBox("does exist")
Application.CommandBars("Freddie").Delete
End If
End Sub