+ Reply to Thread
Results 1 to 11 of 11

Custom Ribbon not executing macros

  1. #1
    Registered User
    Join Date
    08-29-2012
    Location
    Pensacola, FL, USA
    MS-Off Ver
    Excel 2010
    Posts
    5

    Custom Ribbon not executing macros

    I have a set of 6 short and simple macros. Here is one of them:

    Please Login or Register  to view this content.
    Controls placed on worksheets operate the macros perfectly, but controls placed on my custom ribbon (developed with CustomUI) give this error:

    wrong number of arguments or invalid property assignment
    Any theories?
    Last edited by arlu1201; 08-29-2012 at 02:57 PM.

  2. #2
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Custom Ribbon not executing macros

    that's not the right procedure declaration for a ribbon callback. if you use the generate callbacks button in the customui editor you will see the correct declarations

    ---------- Post added at 12:57 PM ---------- Previous post was at 12:49 PM ----------

    Please Login or Register  to view this content.
    is how it should look
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  3. #3
    Registered User
    Join Date
    08-29-2012
    Location
    Pensacola, FL, USA
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Custom Ribbon not executing macros

    Well, something has happened! I now get a different error message, which says "Cannot run the macro gotoLstClk()'. The macro may not be available in this workbook or all macros may be disabled".

    Macros are enable, as I have signed the VBA with a user-created certificate. When I use the View > Macros > View Macros, I cannot see these macros.

  4. #4
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Custom Ribbon not executing macros

    is that actually a macro or is it code behind a command button on a sheet? the code should be in a normal module (not worksheet) and not be marked private
    the routine will not show in the macros dialog because it takes an argument-if you need it there you'll need to keep it as a separate macro and call that from the ribbon callback
    Last edited by JosephP; 08-30-2012 at 01:12 AM.

  5. #5
    Registered User
    Join Date
    08-29-2012
    Location
    Pensacola, FL, USA
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Custom Ribbon not executing macros

    The macros are stored in a module, not a worksheet. The ribbon code in the CustomUI file relevant to that macro (and two similar navigation macros) looks like this:


    HTML Code: 

    I have amended my macros so that they all look similar to this:

    Please Login or Register  to view this content.
    I have removed the 'Private' declaration. Should i make it a 'Public' declaration?
    Last edited by Cutter; 08-30-2012 at 12:56 PM. Reason: Replaced Quote tags with Code tags

  6. #6
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Custom Ribbon not executing macros

    no it will be public by default unless you added option private module to the top of the module. you should not have parentheses on the end of the macro name in the onAction property in your XML.

  7. #7
    Registered User
    Join Date
    08-29-2012
    Location
    Pensacola, FL, USA
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Custom Ribbon not executing macros

    Thanks! It now all works!

    I told you I was rusty - plus there weren't any ribbons last time I was doing this.

    Nevertheless, I think the ribbon system is good, and I used 'CustomUI Editor' to store the CustomUI and the icons, because these macros are only relevant to this individual file. I had previously made the ribbon by Excel's customization, but this meant the ribbon was available in all Excel files, even though it wasn't relevant.

    BTW, I find the interface in 'CustomUI Editor' to be small and not easy to work with. So I actually prepared the code in Notepad++, and copied back and forth.

    I think it is now time for me to investigate adding some more subtle stuff to the ribbon, including passing parameters.

  8. #8
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Custom Ribbon not executing macros

    you may prefer this to the customui editor: http://www.andypope.info/vba/ribboneditor_2010.htm

  9. #9
    Registered User
    Join Date
    08-29-2012
    Location
    Pensacola, FL, USA
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Custom Ribbon not executing macros

    Brilliant! The Ribbon Editor add-in is superb!

  10. #10
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Custom Ribbon not executing macros

    @ neddyseagoon

    Based on your last post it seems that you are satisfied with the solution(s) you've received but you haven't marked your thread as SOLVED. I'll do that for you now but please keep in mind for your future threads that Rule #9 requires you to do that yourself. If your problem has not been solved you can use Thread Tools (located above your first post) and choose "Mark this thread as unsolved".
    Thanks.

    Also, as a new member of the forum, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

  11. #11
    Registered User
    Join Date
    09-26-2019
    Location
    London, England
    MS-Off Ver
    Office 19
    Posts
    2

    Re: Custom Ribbon not executing macros

    This took me a while to work out, but I finally sussed out why my custom ribbon wasn't working:

    The macros associated with each button in the custom ribbon must be linked to the ribbon in the VBE:
    Please Login or Register  to view this content.
    I don't believe you need to Generate Callbacks in the Custom UI Editor, but it can be helpful to do this to check you have linked the macros correctly in VBA.

    A useful tip, you can mouse-scroll up/down while holding CTRL to change the zoom in the Custom UI Editor and make the code more readable without awkward line-wraps.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1