
Command Bar & Button Difficulties
I would like to create a command bar with just one button every time i open
a specific document. So therefore i create the runt eh following procedure
in the document code:
Private Sub Document_DocumentOpened(ByVal doc As IVDocument)
CreateCommandBar
End Sub
The procedure CreateCommandBar is in my module1:
Public Sub CreateCommandBar()
Dim cbrcmdbar As CommandBar
Dim cbButton As CommandBarButton
'create temporary toolbar that doesnt persist between applications
Set cbrcmdbar = Application.CommandBars.Add(Name:="CustomToolBar")
If cbrcmdbar.Enabled = True Then
cbrcmdbar.Visible = True
End If
Set cbButton = cbrcmdbar.Controls.Add(Type:=msoControlButton)
With cbButton
.Caption = "Output File Preview"
.FaceID = 7075
.OnAction = "thisdocument.printunitcode"
.Tag = "cbbVBAMacro"
End With
End Sub
When i open the document i get the following error:
"Runtime Error 5
Invalid Procedure Call or Argument
"
When I debug it points to the procedure above:
-- Set cbrcmdbar = Application.CommandBars.Add(Name:="CaseToolBar") --