Excel User Group
Microsoft Excel blogs, forums, files. Read, ask questions, provide answers.

Resetting a Ribbon Dropdown

Latest post Tue, Jun 8 2010 12:07 PM by Gizmo. 5 replies.
  • Tue, Jun 1 2010 7:52 AM

    • Gizmo
    • Top 10 Contributor
    • Joined on Mon, Jan 21 2008
    • Hampshire, England
    • Posts 105
    • Points 1,687

    Resetting a Ribbon Dropdown

    Hi
    A simple one for a Tuesday morning.

    I have a 'navigation' dropdown on a workbook specific ribbon which works fine except that I don't know how to reset the dropdown button to blank, it retains the value last selected.

    The dropdown XML look like this (shortened list):

    <group id="NaviMenu" label="Navigation" >
      <dropDown id="RP_Navi_DD" showLabel="true" label="Range Plan" onAction="RunRPNavigation" >
         <item id="RP_Navi_1" label="Basic Product" />
         <item id="RP_Navi_2" label="Secondary Product" />
         <item id="RP_Navi_3" label="Staging Dates" />
         <item id="RP_Navi_4" label="Supply Dates" />
         <item id="RP_Navi_5" label="Vendor Info" />
         <item id="RP_Navi_6" label="Approval-Costing" /> 
       </dropDown > 
    </group >

    How can I, either before or after the onAction completes, can I reset the dropdown to Null?

    Thanks

    Giz

    Motto? "There's always a better way" - all you have to do is find it!

    • Post Points: 21
  • Tue, Jun 1 2010 3:28 PM In reply to

    • Nick Hodge
    • Top 10 Contributor
    • Joined on Sun, Dec 23 2007
    • Southampton
    • Posts 543
    • Points 9,287
    • MVP

    Re: Resetting a Ribbon Dropdown

    Giz

    You will have to capture the RibbonUI object and then invalidate it within your dropdown onAction code (RunRPNavigation)

    To do this set an onLoad attribute against your CustomUI in the RibbonX, for example

    <customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"
     onLoad="myRibbonUIonLoad">
    <--Your bits in here-->
    </customUI>

    Now, in your VBA standard module, set a Global Variable at the top of the module as you want it's scope as wide as possible and available to all code in that module., e.g

    Public gRibbonUI as IRibbonUI

    Then in your myRibbonUIonLoad code do something like

    Sub myRibbonUIonLoad(ribbon As IRibbonUI)
        Set gRibbonUI = ribbon
    'Do anything else here, but you now have a handle on the ribbon object (gRibbonUI)
    End Sub

    Now in your RunRPNavigation code you can invalidate the ribbon, which effectievly reloads it, setting your dropdown to null (or anything else you wish to

    Include the line

    gRibbonUI.Invalidate

    That's the theory anyhow ;-)

     

    Regards
    Nick Hodge
    Microsoft MVP, Excel
    Southampton, UK

    Filed under:
    • Post Points: 21
  • Wed, Jun 2 2010 7:39 AM In reply to

    • Gizmo
    • Top 10 Contributor
    • Joined on Mon, Jan 21 2008
    • Hampshire, England
    • Posts 105
    • Points 1,687

    Re: Resetting a Ribbon Dropdown

    Thanks, Nick, you did  say it was the theory.Confused

    It all validates correctly and the gRibbonUI.Invalidate executes OK but nothing changes in the dropdown.

    Thoughts?

    Motto? "There's always a better way" - all you have to do is find it!

    • Post Points: 37
  • Thu, Jun 3 2010 5:05 AM In reply to

    • Nick Hodge
    • Top 10 Contributor
    • Joined on Sun, Dec 23 2007
    • Southampton
    • Posts 543
    • Points 9,287
    • MVP

    Re: Resetting a Ribbon Dropdown

    Giz

    This

    http://msdn.microsoft.com/en-us/library/dd548010.aspx

    Runs down in great detail how to get the ribbon controls to act dynamically. The key is to select the right control, then the right callback and then sort out what needs to fire where and when. It certainly isn't easy.

    I have tried using the comboBox getItemID which should be the one that will allow you to set a certain item from the list in the RibbonX but that doesn't seem to generate a callback stub for me in the CustomUI editor.

    Let us know if the article helped and you found a solution.

    If you can't get this working it maybe you could try another control type?

    Regards
    Nick Hodge
    Microsoft MVP, Excel
    Southampton, UK

    • Post Points: 5
  • Thu, Jun 3 2010 5:56 AM In reply to

    Re: Resetting a Ribbon Dropdown

    Post the file, a workbook is worth a million rows, oops I mean words.

    Regards

    Bob

    • Post Points: 21
  • Tue, Jun 8 2010 12:07 PM In reply to

    • Gizmo
    • Top 10 Contributor
    • Joined on Mon, Jan 21 2008
    • Hampshire, England
    • Posts 105
    • Points 1,687

    Thanks Bob,

    Not quite a mill, but here's a few to take a look at this with. I stripped out a shed load of other stuff hence the #REFs to make this a smaller post.

    When it opens, look at the ribbon tab 'Range Plan Menu' - choose a pre-set destination from the dropdown in the 'Navigation' section.
    It'll go to the destination but then I'd like the dropdown to reset to a blank.
    In time I'd like to build the dropdown on the fly based on whatever is in the navigation table - but that's another learning curve.

    Gary

    Motto? "There's always a better way" - all you have to do is find it!

    • Post Points: 5
Page 1 of 1 (6 items) | RSS
Copyright Excel User Group and the relevant contributors, 2010. All Trade Marks acknowledged. This site is a peer-to-peer site and NOT affiliated in any way to Microsoft Corp. All rights reserved.