Solved

VBA - How to retrieve current dropdown setting in custom MS Office Ribbon menu

Posted on 2016-07-21
5
72 Views
Last Modified: 2016-07-27
Working in Microsoft PowerPoint 2010, I have a custom ribbon menu (toolbar), and I'm using dropdown controls.  I want the user to be able to select a search keyword, which they narrows down the graphics that appear on a dropdown gallery in the button next to it.

Currently I have an onAction macro associated with the dropdown that changes a public variable each time the dropdown is changed.  then the gallery button filters based on that public variable.  How do I accomplish this without relying on a public variable?.  In other words, when the user hits the gallery button, I'd like it to read the current setting of the ribbon dropdown and create the filtered set at that time.  

Appreciate any pointers.
0
Comment
Question by:Bryce Bassett
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 23

Expert Comment

by:JSRWilson
ID: 41723469
You need to post both the XML code and the vba callback.
0
 
LVL 15

Accepted Solution

by:
DrTribos earned 500 total points
ID: 41723803
You can use Get Let Set approach with a Private Variable, so the dropdown would set the private variable and from there you invalidate the ribbon.  When the ribbon is invalidated it resets.  Change the getItem code for the Gallery Callback to include / exclude items based on the variable.

Other approaches, instead of a variable you can use a document property or spreadsheet cell.

Rory Archibald is credited with the solution for ribbon loss of state problem that uses spreadsheet cell. Google that.

Greg Maxey has great tutorials on the Ribbon, which should include "invalidate"

HTH
0
 
LVL 15

Expert Comment

by:DrTribos
ID: 41723806
Oh... if using MS Word... definitely use a document variable to store the ribbon pointer handle as per Rory solution if you're not already doing that (that by the way is not quite related to the original question but well worth the effort).
0
 

Author Closing Comment

by:Bryce Bassett
ID: 41732363
Thanks!  Seems similar to the public variable solution I am using, but I'll try your suggestion.
0
 
LVL 15

Expert Comment

by:DrTribos
ID: 41732365
Doc variable is non volatile, that'd be the main difference
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question