Results 1 to 6 of 6
  1. #1
    3 Star Lounger
    Join Date
    Feb 2001
    Location
    UK
    Posts
    239
    Thanks
    4
    Thanked 1 Time in 1 Post

    Ribbon Creator 2010

    Does anyone here use Ribbon Creator 2010 from http://www.ribboncreator2010.de/en/ ?

    They have given me a sample for a dropdown as below

    Sub OnActionDropDown(control As IRibbonControl, _
    selectedId As String, _
    selectedIndex As Integer)
    ' Callbackname in XML File "OnActionDropDown"
    ' Callback onAction (DropDown)
    Select Case control.id
    'Case "MyItemID"
    Case "ddc_shading"
    Select Case selectedId
    Case "selectedId_For_Red"
    Call YourMacroForRed()
    Case "selectedId_For_Blue"
    Call YourMacroForBlue()
    End Select
    Case Else
    MsgBox "The selected ItemID of DropDown-Control
    """ & control.id & """ is : """ & selectedId & """" & vbCrLf & _
    "Die selektierte ItemID des
    DropDown-Control """ & control.id & """ ist : """ &
    selectedId & """", _
    vbInformation
    End Select
    End Sub

    I believe the lines I need to edit are

    Select Case selectedId
    Case "selectedId_For_Red"
    Call YourMacroForRed()

    The last line is easy as I know my macro name! The only problem there is the VB editor strips out the () when I move line. However, that does not affect buttons I am inserting using Ribbon Creator.

    What I cannot ascertain is what I should be entering as selectedId in the first line and selectedId_For_Red in the second line. I had thought the second line should be the list values but that does not work.

    Any ideas please?

  2. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts
    You don't need the Call word. The basic principle is that the macro is a catch all for potentially several different drop down buttons. The Select Case line is intended to specify which dropdown was clicked (not which entry was chosen). Once the code works out which control called it, it then needs to work out which list item was chosen.

    In the code, the structure which starts Select Case is where this macro determines which action is required. If your dropdown control id is "
    ddc_shading" and the list entries are "Red" and "Blue" then I would expect the code to follow this pattern. Note that this nests one or more Select cases inside the outer one.
    Sub OnActionDropDown(control As IRibbonControl,
    selectedId As String, selectedIndex As Integer) Select Case control.id
    Case "ddc_shading"
    Select Case selectedId
    Case "Red"
    YourMacroForRed
    Case "Blue"
    YourMacroForBlue
    Case Else
    MsgBox "You selected neither Red, nor Blue in the ddc_shading list"
    End Select
    Case Else
    MsgBox "You selected an entry on a control that I didn't expect"
    End Select
    End Sub
    Last edited by Andrew Lockton; 2012-06-14 at 20:46.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  3. #3
    3 Star Lounger
    Join Date
    Feb 2001
    Location
    UK
    Posts
    239
    Thanks
    4
    Thanked 1 Time in 1 Post
    Andrew

    Thank you and apologies for my slow response.

    Prior to you coming back, I edited the supplied code as below and that seems to work.

    Sub OnActionDropDown(control As IRibbonControl, _
    selectedId As String, _
    selectedIndex As Integer)

    Select Case selectedId
    Case "ddcBorderColourItem0"
    MsgBox "You must select a colour.", vbOKOnly
    Case "ddcBorderColourItem1"
    Call TableBordersGrey
    Case "ddcBorderColourItem2"
    Call TableBordersBlue
    Case "ddcBorderColourItem3"
    Call TableBordersNone
    Case "ddcShadingColourItem0"
    MsgBox "You must select a colour.", vbOKOnly
    Case "ddcShadingColourItem1"
    Call ShadingGrey
    Case "ddcShadingColourItem2"
    Call ShadingBlue
    Case "ddcShadingColourItem3"
    Call ShadingYellow
    Case "ddcShadingColourItem4"
    Call ShadingNone
    Case Else
    MsgBox "The selected ItemID of DropDown-Control """ & control.id & """ is : """ & selectedId & """" & vbCrLf & _
    "Die selektierte ItemID des DropDown-Control """ & control.id & """ ist : """ & selectedId & """", _
    vbInformation
    End Select

    End Sub

    ****************************************

    Since then my problem has changed. If I put code for buttons as below into one global template it works fine.

    Public Sub OnActionButton(control As IRibbonControl)
    'Callback in XML File "onAction"

    ' Callback for event button click
    ' Callback für Button Click

    Select Case control.id
    Case "btn1"
    Call ChangeStyles.ShowChangeStyles
    Case "btn2"
    Call InsertDates.InsertAbbDate
    Case "btn3"
    Call InsertDates.InsertFullDate
    Case "btn4"
    Call Remove.RemoveSectionBreaks
    Case Else
    MsgBox "Button """ & control.id & """ clicked" & vbCrLf & _
    "Es wurde auf Button """ & control.id & """ in Ribbon geklickt", _
    vbInformation
    End Select
    End Sub

    If I put similar code (same button names, different module and macro names) into a second global template, that too will work if it is the only global template. If I put both global templates into Word > Startup, one works and the other gives me the message above. It tells me the name of the button that has been clicked and not found a macro. It can find the macro if it is the only global template but not if there is another.

    The code is held in a module name basCallbacks which the name given by Ribbon Creator 2010. I don't know enough to know if the module can be given a different name or whether Ribbon Creator relies on that name.

  4. #4
    3 Star Lounger
    Join Date
    Feb 2001
    Location
    UK
    Posts
    239
    Thanks
    4
    Thanked 1 Time in 1 Post
    OK. In the second template Public Sub OnActionButton needs to be Public Sub OnActionButton2 (or at least have some differentation).

  5. #5
    Silver Lounger Charles Kenyon's Avatar
    Join Date
    Jan 2001
    Location
    Sun Prairie, Wisconsin, Wisconsin, USA
    Posts
    2,048
    Thanks
    124
    Thanked 119 Times in 116 Posts
    I suspect that you need different button names and module names if both are running. I assume you do not have this problem if only one global template is running at a time. You might be able to get away with a button in each template that loads the other template and unloads itself if you don't need both loaded at the same time.

    I would recommend looking at Customize the Ribbon (It doesn't take rocket science) and RibbonX: Customizing the Office 2007 Ribbon which teach more about XML ribbon editing. The Custom UI Editor (free) may not be as full-featured as Ribbon Creator but you certainly are free to name your own modules and buttons.
    Last edited by Charles Kenyon; 2012-06-26 at 13:47.
    Charles Kyle Kenyon
    Madison, Wisconsin

  6. #6
    3 Star Lounger
    Join Date
    Feb 2001
    Location
    UK
    Posts
    239
    Thanks
    4
    Thanked 1 Time in 1 Post
    Thanks Charles but with the change I posted above, everything is working fine with both global templates running, even with identical module and macro names in both templates. The trick is the code calling the buttons has to be in a macro with a unique name in each template and the buttons' OnAction property (if that is the right word) has to have the same name.

  7. The Following User Says Thank You to Peter Grainge For This Useful Post:

    Charles Kenyon (2012-06-27)

Posting Permissions

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