Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

add-in problems and macros from menus

Status
Not open for further replies.

NightZEN

Programmer
Apr 29, 2003
142
US
I am trying to create and add-in that will add a menu item for users to click and call a macro called "HotList_Formating". I have the following code saved in an add-in file (hotlist_formater.xla) in it's "ThisWorkbook" Object. I did not include the called subroutines here to save space, but they are saved in the same location. When I add the add-in and click the menu button I get the following error:

"The macro 'hotlist_formater.xla!HotList_Formating' cannot be found."

Why Not? Please helop me to understand where I'm going wrong. Thanks!!!!!

Code:
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("HotList Formater").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 = "HotList Formater"
            .Style = msoButtonCaption
            .OnAction = "'" & ThisWorkbook.Name & "'!HotList_Formating"
            '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("HotList Formater").Delete
    On Error GoTo 0
End Sub

Sub HotList_Formating()
'
' HotList_Formating Macro
' Changes a cell's color based on the workcenter.
'

'
   Call AddHeaderColor
   Call AddLines
   Call ChangeColor("M4:M2000")
   Call ChangeColor("J4:J2000")
   
End Sub
 


Hi,

This is a code question.

Please post in VBA Visual Basic for Applications (Microsoft) Forum707

Skip,

[glasses] [red]Be Advised![/red] A chicken, who would drag a wagon across the road for 2 cents, is…
POULTRY in motion to PULLET for a PALTRY amount! [tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top