Can resources embedded in Ribbon CustomUI\images be used elsewhere?

Mr Axolotl

New member
Joined
Apr 4, 2012
Messages
7
Reaction score
0
Points
0
Location
Central Europe
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
 

Ken Puls

Administrator
Staff member
Joined
Mar 13, 2011
Messages
2,521
Reaction score
6
Points
38
Location
Nanaimo, BC, Canada
Website
www.excelguru.ca
Excel Version(s)
Excel Office 365 Insider
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.
 

Andy Pope

New member
Joined
Mar 22, 2011
Messages
43
Reaction score
0
Points
0
Location
London, England
Website
www.andypope.info
Excel Version(s)
2016
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.

View attachment RibbonItems.xlsm
 

Mr Axolotl

New member
Joined
Apr 4, 2012
Messages
7
Reaction score
0
Points
0
Location
Central Europe
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.
 

Bob Phillips

Super Moderator
Staff member
Joined
Mar 21, 2011
Messages
1,940
Reaction score
0
Points
36
Excel Version(s)
O365
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.
 

Mr Axolotl

New member
Joined
Apr 4, 2012
Messages
7
Reaction score
0
Points
0
Location
Central Europe
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.
 

Bob Phillips

Super Moderator
Staff member
Joined
Mar 21, 2011
Messages
1,940
Reaction score
0
Points
36
Excel Version(s)
O365
Which is exactly what I suggested.
 
Top