J
Jason Morin
Hello. Below is some Dave Peterson code that I found (and modified). I simply
want to create a floating toolbar with one button for my macro. However,
whenever I start Excel or uninstall/install this add-in, it errors out on
naming the commandbar. I get "Invalid procedure call or argument". It seems
to be naming the commandbar "Custom 1", and then it won't rename it. I'm
puzzled. thanks.
'===========================================
Sub Autpen()
Call CreateMenubar
End Sub
'===========================================
Sub Auto_Close()
Call RemoveMenubar
End Sub
'===========================================
Sub RemoveMenubar()
On Error Resume Next
Application.CommandBars("View").Delete
On Error GoTo 0
End Sub
'===========================================
Sub CreateMenubar()
Call RemoveMenubar
With Application.CommandBars.Add
.Name = "View" '<<<<<<<<<Errors here
.Left = 200
.Top = 200
.Protection = msoBarNoProtection
.Visible = True
.Position = msoBarFloating
With .Controls.Add(Type:=msoControlButton)
.OnAction = "'" & ThisWorkbook.Name & "'!" & "Unhide_All_WS"
.Caption = "Unhide All Sheets"
.Style = msoButtonIconAndCaption
.FaceId = 229
End With
End With
End Sub
want to create a floating toolbar with one button for my macro. However,
whenever I start Excel or uninstall/install this add-in, it errors out on
naming the commandbar. I get "Invalid procedure call or argument". It seems
to be naming the commandbar "Custom 1", and then it won't rename it. I'm
puzzled. thanks.
'===========================================
Sub Autpen()
Call CreateMenubar
End Sub
'===========================================
Sub Auto_Close()
Call RemoveMenubar
End Sub
'===========================================
Sub RemoveMenubar()
On Error Resume Next
Application.CommandBars("View").Delete
On Error GoTo 0
End Sub
'===========================================
Sub CreateMenubar()
Call RemoveMenubar
With Application.CommandBars.Add
.Name = "View" '<<<<<<<<<Errors here
.Left = 200
.Top = 200
.Protection = msoBarNoProtection
.Visible = True
.Position = msoBarFloating
With .Controls.Add(Type:=msoControlButton)
.OnAction = "'" & ThisWorkbook.Name & "'!" & "Unhide_All_WS"
.Caption = "Unhide All Sheets"
.Style = msoButtonIconAndCaption
.FaceId = 229
End With
End With
End Sub