Creating toolbar macro errors

G

Guest

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 Auto_Open()
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
 
J

JE McGimpsey

You need to choose a name that's not already being used by another
commandbar.
 

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

Similar Threads

One more time (I hope) 3
Subscript out of range error? 3
Old Toolbar won't go away 5
Custom Toolbar Add-in 1
Create toolbar 1
Floating Vertical Menu bar....Please help 4
toolbar won't go away 9
Custom Toolbars 2

Top