S
salgud
I've tried at least a dozen variations on creating this command bar, none
of which works:
Sub CreateOSIMenubar()
Dim vMacNames As Variant
Dim vCapNames As Variant
Dim vTipText As Variant
Dim cbOSI As CommandBar
Call RemoveOSIMenubar
vMacNames = "OSILogInsertRow"
vCapNames = "OSILogInsertRow"
vTipText = "Add Row"
Set cbOSI = CommandBars.Add
With cbOSI
.Name = vMacNames <--- Invalid Procedure call or argument
.Left = 200
.Top = 200
.Protection = msoBarNoProtection
.Visible = True
.Position = msoBarTop
.Left = CommandBars("FormatDGB").Left + CommandBars("FormatDGB").Width
.RowIndex = CommandBars("FormatDGB").RowIndex
End With
With CommandBars("OSILogInsertRow").Controls.Add(Type:=msoControlButton)
.OnAction = "'" & ThisWorkbook.Name & "'!" & "OSILogInsertRow"
.Caption = vCapNames
.Style = msoButtonCaption
.TooltipText = vTipText
End With
End Sub
I've typed in the text string instead of the variable, changed the variable
to a string, etc, etc.
Does anyone see what's wrong here?
of which works:
Sub CreateOSIMenubar()
Dim vMacNames As Variant
Dim vCapNames As Variant
Dim vTipText As Variant
Dim cbOSI As CommandBar
Call RemoveOSIMenubar
vMacNames = "OSILogInsertRow"
vCapNames = "OSILogInsertRow"
vTipText = "Add Row"
Set cbOSI = CommandBars.Add
With cbOSI
.Name = vMacNames <--- Invalid Procedure call or argument
.Left = 200
.Top = 200
.Protection = msoBarNoProtection
.Visible = True
.Position = msoBarTop
.Left = CommandBars("FormatDGB").Left + CommandBars("FormatDGB").Width
.RowIndex = CommandBars("FormatDGB").RowIndex
End With
With CommandBars("OSILogInsertRow").Controls.Add(Type:=msoControlButton)
.OnAction = "'" & ThisWorkbook.Name & "'!" & "OSILogInsertRow"
.Caption = vCapNames
.Style = msoButtonCaption
.TooltipText = vTipText
End With
End Sub
I've typed in the text string instead of the variable, changed the variable
to a string, etc, etc.
Does anyone see what's wrong here?