Hi,
I am trying to create a new add in for excel. I have the add in created but I cant get a new custom menu working. It will not show up on the menu bar no matter what code I throw at it. I am new at doing this type of thing so I must be doing something wrong but I can't figure out what.
I had been following instructions on this website:
http://www.ozgrid.com/VBA/excel-add-in-create.htm
Like I said I have the add-in created as an xla and when I run it from the VB editor t runs fine and the macro will run int he document. I am going to be distributing this addin to a few clients and just want to create a simple menu on the menu bar to be able to run the macro in the add-in but even though I used the code on that website no new menu is being added to excel.
I am adding this code into "ThisWorkbook" in VB under the xla I made.
Here is the code I am using:
Option Explicit
Dim cControl As CommandBarButton
Private Sub Workbook_AddinInstall()
On Error Resume Next 'Just in case
'Delete any existing menu item that may have been left.
Application.CommandBars("Worksheet Menu Bar").Controls("Super Code").Delete
'Add the new menu item and Set a CommandBarButton Variable to it
Set cControl = Application.CommandBars("Worksheet Menu Bar").Controls.Add
'Work with the Variable
With cControl
.Caption = "Super Code"
.Style = msoButtonCaption
.OnAction = "MyGreatMacro"
'Macro stored in a Standard Module
End With
On Error GoTo 0
End Sub
Private Sub Workbook_AddinUninstall()
On Error Resume Next 'In case it has already gone.
Application.CommandBars("Worksheet Menu Bar").Controls("Super Code").Delete
On Error GoTo 0
End Sub
Any help would be great.
Bookmarks