This is the code for the command bar. It is in an Add-in I created in the Workbook_Open Event procedure.
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
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