Automation error with XLA addin, fails on commandbarbutton onaction

H

haydnlj

Hello,

I have a series of procedures in a file named auto.xla. The
workbook_open() procedure runs the below code, and effectively adds a
custom menu to the users main menu. It has mysteriously stopped
working, stepping through this code presents a Run-Time error
'-2147467259 (80004005)' suggesting the 'OnAction' of
object'_commandbarbutton' failed. The strange part is that if I copy
this workbook and create a file named auto_2.xla for example, this
opens and executes as expected.

The code bugs out on line 26, the first OnAction method. As discussed
this was working just fine, any help would be appreciated.


Private Sub Workbook_Open()

With Application.CommandBars("Worksheet Menu Bar")

If .Controls.Item(1).Caption = "[ CUSTOM MENU ]" Then
.Controls.Item(1).Delete
End If

Set cp = .Controls.Add(Type:=msoControlPopup, Before:=1,
Temporary:=True)
End With
cp.Caption = "[ CUSTOM MENU ]"
i = 0
Application.CommandBars("Worksheet Menu
Bar").Controls("File").BeginGroup = True

With cp.Controls

i = i + 1
Set cp2 = .Add(Type:=msoControlPopup, Temporary:=True)
.Item(i).Caption = "Internal Quoting"
With cp2.Controls
t = i

i = 1
.Add Type:=msoControlButton, Temporary:=True
.Item(i).Caption = "Eclipse -> Quote"
.Item(i).OnAction = "Eclipse_To_Quote"
.Item(i).FaceId = 2671

i = i + 1
.Add Type:=msoControlButton, Temporary:=True
.Item(i).Caption = "Quote -> Excel"
.Item(i).OnAction = "QP_TO_Excel"
.Item(i).FaceId = 317

i = t
End With

i = i + 1
Set cp2 = .Add(Type:=msoControlPopup, Temporary:=True)
.Item(i).Caption = "Direct Quoting"
With cp2.Controls
t = i

i = 1
.Add Type:=msoControlButton, Temporary:=True
.Item(i).Caption = "Quote Search"
.Item(i).OnAction = "quote_lookup"
.Item(i).FaceId = 558
.Item(i).BeginGroup = True

i = i + 1
.Add Type:=msoControlButton, Temporary:=True
.Item(i).Caption = "Controlâ„¢"
.Item(i).OnAction = "Create_fControl"
.Item(i).FaceId = 3251

i = i + 1
.Add Type:=msoControlButton, Temporary:=True
.Item(i).Caption = "Systemâ„¢"
.Item(i).OnAction = "M_Quotes"
.Item(i).FaceId = 3251
.Item(i).BeginGroup = True

i = i + 1
.Add Type:=msoControlButton, Temporary:=True
.Item(i).Caption = "CVault"
.Item(i).OnAction = "CV_Quotes"
.Item(i).FaceId = 3251

i = t
End With

i = i + 1
.Add Type:=msoControlButton, Temporary:=True
.Item(i).Caption = "Margin Calculator"
.Item(i).OnAction = "mycalcshow"
.Item(i).FaceId = 283
.Item(i).BeginGroup = True

i = i + 1
.Add Type:=msoControlButton, Temporary:=True
.Item(i).Caption = "Integration Build"
.Item(i).OnAction = "integration_build"
.Item(i).FaceId = 627

i = i + 1
.Add Type:=msoControlButton, Temporary:=True
.Item(i).Caption = "Quick Typer"
.Item(i).OnAction = "Quick_Typer"
.Item(i).FaceId = 3479

End With

End Sub
 

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

Top