none
Using RibbonCreator and need help with custom global and template RRS feed

  • Question


  • Hi,

    I am using RibbonCreator (www.ribboncreator.com) to customise our company ribbon and use as a global template, which is opened at Word startup.

    I have done this with success, adding buttons for custom macros and for launching other custom templates. The module in my global template is called basCallbacks and in here I have customised the OnActionButton routine which calls my various macros. This works fine - I see my customised ribbon, with custom buttons, which fire macros to open new documents based on templates.

    I have around 20 templates I also need to customise the menu for. With the first template, I also added a custom ribbon with it's own buttons for macros unique to that template. The problem is, with a document open which is based on this template, non of my global macros work anymore. The error I get is 

    Button "btnPrintMacro" clicked
    Es wurde auf Button "btnPrintMacros" in Ribbon geklickt

    This is because for the currently loaded document, which is based on a template, does not have the buttons for the global within its OnActionButton routine.

    Hope this makes sense. How can I fix this? 

    Thanks.

    Thursday, June 27, 2013 10:39 AM

Answers

  • Hi Wall-It

    Yes, the problem is that you have (had) two procedures with the same name. The most local one will then take precedence.

    You can name a ribbon callback with any name you like, as long as you use the same name in the onAction attribute of the Ribbon XML that should tirgger the callback.


    Cindy Meister, VSTO/Word MVP, my blog

    Wednesday, July 3, 2013 12:52 PM
    Moderator

All replies

  • Hi Wall-It,

    Have you tried to contact the RibbonCreator to ask for help.

    http://www.ribboncreator.de/en/?Support


    • Edited by WhCatalpa Tuesday, July 2, 2013 9:46 AM Add the link.
    Tuesday, July 2, 2013 9:46 AM
  • That's not really an "error", but rather it means that the button the user clicked does not have any custom code. The "error" you're reporting is just a placeholder put there by the RibbonCreator. You'd have to add your own custom code to perform whatever action you'd like.

    The callbacks are located in a Standard Module named "basRibbonCallbacks" in the OnActionButton subroutine. You should see something like this:

    Dim i As Integer
    Dim frm As Form
    
    Select Case control.id
        Case "btnAppExit" 
           ' In Tab:   tab0 
           ' In Group: grpApplication 
           <Your customer code here >
        Case "btnLogout" 
           ' In Tab:   tab0 
           ' In Group: grpApplication 
           <Your custom code here>
        Case "btnWO_Edit" 
           ' In Tab:   tab0 
           ' In Group: grpWorkOrders
      <Your Custom Code Here>etc etc


    -- Scott McDaniel, Microsoft Access MVP

    Tuesday, July 2, 2013 10:21 AM
  • Hi Wall-It,

    Welcome.

    I've moved the thread for better support. 

    Thanks for your understanding and have a nice day.


    Yoyo Jiang[MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, July 2, 2013 11:03 AM
    Moderator
  • Hi Wall-It

    I'm not sure where you posted originally, nor why the message was moved, since it seems Scott McDaniel is at least familiar with the tool you've used to customize the Ribbon. Has his information helped you? It sounds reasonable...


    Cindy Meister, VSTO/Word MVP, my blog

    Tuesday, July 2, 2013 3:07 PM
    Moderator
  • I did contact them and they don't offer direct support, but sent me links to these forums instead.
    Tuesday, July 2, 2013 6:20 PM
  • Thanks Scott. And you're right, the 'error' was just a place-holder for an action. 

    The short answer is I have worked around the problem, by using another example I found online and editing in the 'Custom UI editor for Microsoft Office'. I used this example

    So, I never solved my original issue...

    I can add code for each button's OnAction, which works fine in isolation (using a single document at a time). However, when I have some code in my Global, and some other code in my document template, and I have a document open (which is based on the template) then the code from the global won't run and I get the message above. Only the code from the active document will work. If I close this, my Global buttons will work again.

    Let me explain better with an example...

    Global.dotm contains a custom ribbon with a button to, say, add a footer to a document. I launch Word, the global loads from my startup folder and shows my custom ribbon. With a standard blank document open, I can press the button and it adds a footer. The code is...

    Public Sub OnActionButton(control As IRibbonControl) 'Callback in XML File "onAction" ' Callback for event button click Select Case control.id Case "btnAddFooter" Module1.AddCustomFooter

    Case Else MsgBox "Button """ & control.id """ clicked" & vbCrLf
    End Select
    End Sub


    Letter.dotm contains it's own custom ribbon with a button to, say, print to a particular printer. If I launch Word, my global loads from the startup folder showing my global custom ribbon. I then open a document based on this template and I see another custom ribbon with a button for printing. I can press the printing button and my document will print. But I cannot add a custom footer from the Global custom ribbon. I get the message

    Button "btnAddFooter" clicked

    ...which I appreciate is the developers place holder for code. The code from my printing macro in Letter.dotm is very similar to the code found in the Global.

    Public Sub OnActionButton(control As IRibbonControl) 'Callback in XML File "onAction" ' Callback for event button click Select Case control.id Case "btnPrintMacro" Module1.PrintToHP

    Case Else MsgBox "Button """ & control.id """ clicked" & vbCrLf
    End Select
    End Sub


    Anyway, I have now worked around the problem, but if anyone can explain why this happens I would be interested to know. Is It because there are two 'Public' subroutines?

    Thanks in advance

    Tuesday, July 2, 2013 6:45 PM
  • My reply is below Scott's.
    Tuesday, July 2, 2013 6:45 PM
  • Hi Wall-It

    Yes, the problem is that you have (had) two procedures with the same name. The most local one will then take precedence.

    You can name a ribbon callback with any name you like, as long as you use the same name in the onAction attribute of the Ribbon XML that should tirgger the callback.


    Cindy Meister, VSTO/Word MVP, my blog

    Wednesday, July 3, 2013 12:52 PM
    Moderator