One Workbook Disables My Commandbar Buttons...Why?

murphy00

New Member
Joined
Feb 17, 2002
Messages
15
This is the code for the command bar. It is in an Add-in I created in the Workbook_Open Event procedure.

Code:
Sub App_WorkbookOpen(ByVal Wb As Excel.Workbook)
Dim cmdBar As CommandBar
Dim btnLink As CommandBarButton
Dim z As Integer
On Error Resume Next
Application.CommandBars("HW").Delete
Set cmdBar = Application.CommandBars.Add
cmdBar.name = "HW"
cmdBar.Position = msoBarBottom
For z = 1 To Application.Workbooks.count
Set btnLink = cmdBar.Controls.Add(msoControlButton)
With btnLink
.BeginGroup = True
.style = msoButtonCaption
.Caption = Workbooks(z).name
.FaceId = 0
.OnAction = "getSheet"
.TooltipText = ""
.Visible = True
End With

Next z
cmdBar.Visible = True
cmdBar.Position = msoBarTop
End Sub

It works fine with all workbooks except one. The problem book is called
Database.xls.

If I use the Window menu to switch to another workbook while Database.xls is still open then the toolbar will work fine until I go back to that workbook.
I put a stop in the getSheet procedure and the problem lies in the CommandBar itself. When Database.xls is the active workbook the button .OnAction never gets to the getSheet procedure.

Any ideas as to what could be happening?

Thank you,
Murph
 

Some videos you may like

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.

murphy00

New Member
Joined
Feb 17, 2002
Messages
15
Like Homer would say... "DOH!"

In the Database.xls I had a macro with the same name.
I changed the name and it works fine now.
 

Watch MrExcel Video

Forum statistics

Threads
1,127,554
Messages
5,625,471
Members
416,108
Latest member
Ravenhold

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top