Hmm... good question... I'd have to experiment with that one, as I'm not sure off the top of my head how to get to them.
I have been adding my own custom images to the CustomUI\images subdirectory. These are typically .png files and are used in the ribbon in the usual way.
Suppose I need the same image files elsewhere in the same application, but to be accessed from VBA. Perhaps a logo, or maybe country flags for use in a tree view control, or something. Is there a way to access these image resources from VBA, conceptually opposite to "Loading Custom Pictures On-the-Fly" (p.268, RibbonX book)?
What appeals to me about the new Office 2007-2010 formats is that they are self-contained. It would be useful to be able to park images and possibly other resources in the CustomUI.
Thanks, Mr Axolotl
Hmm... good question... I'd have to experiment with that one, as I'm not sure off the top of my head how to get to them.
Ken Puls, FCPA, FCMA, MS MVP
Learn to Master Your Data at the Power Query Academy (the world's most comprehensive online Power Query training), with my book M is for Data Monkey, or our new Power Query Recipe cards!
Main Site: http://www.excelguru.ca -||- Blog: http://www.excelguru.ca/blog -||- Forums: http://www.excelguru.ca/forums
Check out the Excelguru Facebook Fan Page -||- Follow Me on Twitter
If you've been given VBA code (a macro) for your solution, but don't know where to put it, CLICK HERE.
Thanks by the way for the RibbonX book. VERY useful.
I don't think there is a way, within the existing OM, to access any of the ribbonx content of the open file.
That said you can work around those limitations. This example creates a temporary copy of the workbook in order to extract the required information.
The workbook adds a new tab to the ribbon with 3 buttons. Clicking a button will copy the associated image on to the activesheet.
If you workbook is large this may not be a suitable approach. Instead it might be better to duplicate the imagery on a hidden worksheet.
RibbonItems.xlsm
Thanks. Nice approach.
I'll play around with the code and see if I can refine the solution to create a temporary directory (not unlike the ~$addin.xlam files created by Excel) which exists just for the duration of the session containing only the necessary files.
Why don't you store the .png files in the workbook directory instead of loading them in the CustomUI and use the GDI load to load them dynamically (all explained in the RibbonX book). You can then load them in your application as required.
Thanks for the reply and suggestion.
First, I need to do something similar in Word.
Second, I want to share the images with the ribbon itself, then use them again in a tree view. For the tree view, the images need to be saved on disk somewhere.
Which is exactly what I suggested.
Bookmarks