Solved

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

Posted on 2016-07-21
5
61 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:versatilebb
  • 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:versatilebb
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.

726 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