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
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
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.
 
Upvote 0

Forum statistics

Threads
1,214,599
Messages
6,120,448
Members
448,966
Latest member
DannyC96

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
Back
Top