I have a fully functional Macro that I'm trying to convert to an Add-In so I can use it on all excel documents. However I can't get it create a menu. Please Help.
First Things First:
I'm using Office 2011-Excel on a Mac running Mountain Lion
My .xlam file is saved in the correct folder Applications/Microsoft Office 2011/Office/Add-Ins
I've installed it correctly using the Tools/Add-Ins menu
My code is in the This Worksheet section of the .xlam file
My Add-In's source code is viewable from all documents
My code as follows:
Option Explicit
Dim cControl As CommandBarButton
Private Sub Workbook_Open()
On Error Resume Next 'Just in case
Application.CommandBars("Worksheet Menu Bar").Controls("P Wave").Delete 'Delete any existing menu item that may have been left.
Set cControl = Application.CommandBars("Worksheet Menu Bar").Controls.Add 'Add the new menu item and Set a CommandBarButton Variable to it
With cControl 'Work with the Variable
.Caption = "P Wave"
.Style = msoButtonCaption
.OnAction = "runSheet()"
'Macro stored in a Standard Module
End With
On Error GoTo 0
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error Resume Next 'In case it has already gone.
Application.CommandBars("Worksheet Menu Bar").Controls("P Wave").Delete
On Error GoTo 0
End Sub
I can't get my Macro menu to appear. Please help