M
Mario
Hello ,
I found (at http://www.ozgrid.com/VBA/excel-add-in-create.htm ) the
following code on the net and i'm trying to use it:
When adding the AddIn , i get an error message 'Invalid procedure call or
argument'
What is the problem here ?
On adding the AddIn , the code is trying to delete a control that is not
there or not created yet.
Do I need extra code to find the control first before deleting it ?
Thanks for helping me with this .
Mario
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 = "StartMCR"
'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
I found (at http://www.ozgrid.com/VBA/excel-add-in-create.htm ) the
following code on the net and i'm trying to use it:
When adding the AddIn , i get an error message 'Invalid procedure call or
argument'
What is the problem here ?
On adding the AddIn , the code is trying to delete a control that is not
there or not created yet.
Do I need extra code to find the control first before deleting it ?
Thanks for helping me with this .
Mario
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 = "StartMCR"
'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