Syntax for menu option to execute macro or code

I need to add a menu option to an existing shortcut menu used in one of our applications.  I didn't not create the menu and barely understand how it was created.  The routine uses predefined Office number to tell the command what to execute when the option is selected.  This is the routine that creates the menu

'////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Public Sub Create2013_ReportRightClickMenu()

On Error Resume Next
   
  '  CommandBars("2013_ReportRightClick").Delete
    CommandBars("ReportRightClick").Delete
   
    Dim cmbRightClick As Office.CommandBar
    Dim cmbControl As Office.CommandBarControl

    Set cmbRightClick = CommandBars.Add("2013_ReportRightClick", _
                                        msoBarPopup, False, False)
    With cmbRightClick
       
        ' Add the Print command.
        Set cmbControl = .Controls.Add(msoControlButton, 2521)
        ' Change the caption displayed for the control.
        cmbControl.Caption = "Quick Print"
       
        ' Add the Print command.
        Set cmbControl = .Controls.Add(msoControlButton, 15948)
        ' Change the caption displayed for the control.
        cmbControl.Caption = "Print ..."
       
'        ' Add the Page Setup... command.
'        Set cmbControl = .Controls.Add(msoControlButton, 247)
'        ' Change the caption displayed for the control.
'        cmbControl.Caption = "Page Setup ..."
       
        ' Add the Mail Recipient (as Attachment)... command.
        Set cmbControl = .Controls.Add(msoControlButton, 2188)
        ' Start a new group.
        cmbControl.BeginGroup = True
        ' Change the caption displayed for the control.
        cmbControl.Caption = "Email Report as an Attachment"
       
        ' Add the Export To Excel.
        Set cmbControl = .Controls.Add(msoControlButton, 11723)
        ' Change the caption displayed for the control.
        cmbControl.Caption = "Export To Excel"
       
        ' Add the PDF or XPS command.
        Set cmbControl = .Controls.Add(msoControlButton, 11725)
        ' Change the caption displayed for the control.
        cmbControl.Caption = "Expport To Word"
       
       
        ' Add the PDF or XPS command.
        Set cmbControl = .Controls.Add(msoControlButton, 12499)
        ' Change the caption displayed for the control.
        cmbControl.Caption = "Save as PDF/XPS"
     
       
    End With
   
    Set cmbControl = Nothing
    Set cmbRightClick = Nothing
End Sub
'
'////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

I need to add an option that will either runcode or execute a macro.  I can set it up either way.  How to I change the command:

       cmbControl = .Controls.Add(msoControlButton, 12499)
 
to executue a macro 'CC2013_Macros.OpenPayForm'  or
execute a function called "openPayForm"
LVL 1
mlcktmguyAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dale FyeOwner, Developing Solutions LLCCommented:
Read my articles on Commandbars.  For what you want, you should probably start with #2, but reading #1 will help you understand the CommandBar object.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mlcktmguyAuthor Commented:
Just what I needed, thanks.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.