Invalid procedure call or argument

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top