S
salgud
I've cobbled together the following code to create a toolbar everytime a
certain spreadsheet opens:
Sub CreateOSIMenubar()
Dim vMacNames As Variant
Dim vCapNames As Variant
Dim vTipText As Variant
Call RemoveOSIMenubar
vMacNames = "OSILogInsertRow"
vCapNames = "OSILogInsertRow"
vTipText = "Add Row"
With Application.CommandBars
.Add
.Name = vMacNames <----- Compile Error: Method or Data Member not found
.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(vMacNames).Controls.Add(Type:=msoControlButton)
.OnAction = "'" & ThisWorkbook.Name & "'!" & vMacNames
.Caption = vCapNames
.Style = msoButtonCaption
.TooltipText = vTipText
End With
End Sub
Doesn't recognize the name variable or something. Any ideas?
Thanks
certain spreadsheet opens:
Sub CreateOSIMenubar()
Dim vMacNames As Variant
Dim vCapNames As Variant
Dim vTipText As Variant
Call RemoveOSIMenubar
vMacNames = "OSILogInsertRow"
vCapNames = "OSILogInsertRow"
vTipText = "Add Row"
With Application.CommandBars
.Add
.Name = vMacNames <----- Compile Error: Method or Data Member not found
.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(vMacNames).Controls.Add(Type:=msoControlButton)
.OnAction = "'" & ThisWorkbook.Name & "'!" & vMacNames
.Caption = vCapNames
.Style = msoButtonCaption
.TooltipText = vTipText
End With
End Sub
Doesn't recognize the name variable or something. Any ideas?
Thanks