Solved

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

Posted on 2016-07-21
5
38 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 14

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 14

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 14

Expert Comment

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

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

This is written from a 'VBA for MS Word' perspective, but I am sure it applies to most other MS Office components where VBA is used.  One thing that really bugs me is slow code, ESPECIALLY when it's mine!  In programming there are so many ways to…
PaperPort has a feature called the "Send To Bar". It provides a convenient, drag-and-drop interface for using other installed software, such as Microsoft Office. However, this article shows that the latest Office 2016 apps (installed with an Office …
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

707 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now