I know how to add a Command Bar and populate it, but I can't seem to crack how to test that the Command Bar exists before either creating it or, when the document is finished with, deleting it.
What would my opening line(s) be in the following code to check this before completing the rest of the macro or ending.
Sub AutoOpen()
If CommandBars("Invoice Request") = True Then Exit Sub
Set cbar1 = CommandBars.Add(Name:="Invoice Request", Position:=msoBarTop)
cbar1.Visible = True
Set oldControl = cbar1.Controls.Add(Type:=msoControlButton)
With oldControl
.Style = msoButtonCaption
.Caption = "Invoice Request"
.FaceId = 204
.OnAction = "Filler"
.TooltipText = "Run Invoice Request Filler"
End With
End Sub
Sub AutoClose()
CommandBars("Invoice Request").Delete
End Sub
What would my opening line(s) be in the following code to check this before completing the rest of the macro or ending.
Sub AutoOpen()
If CommandBars("Invoice Request") = True Then Exit Sub
Set cbar1 = CommandBars.Add(Name:="Invoice Request", Position:=msoBarTop)
cbar1.Visible = True
Set oldControl = cbar1.Controls.Add(Type:=msoControlButton)
With oldControl
.Style = msoButtonCaption
.Caption = "Invoice Request"
.FaceId = 204
.OnAction = "Filler"
.TooltipText = "Run Invoice Request Filler"
End With
End Sub
Sub AutoClose()
CommandBars("Invoice Request").Delete
End Sub