Personal website of Gregory K. Maxey, Commander USN (Retired)
Do you have ad-blocking software enabled? While I respect your right to do so, your donations and the minimal advertisements on this site help to defray internet and other costs of providing this content. Please consider excluding this website from blocking or turning off the blocker while browsing this site.
The information, illustrations and code contained in my "Microsoft Word Tips" are provided free and without risk or obligation.
However, the work is mine. If you use it for commercial purposes or benefit from my efforts through income earned or time saved then a donation, however small, will help to ensure the continued availability of this resource.
If you would like to donate, please use the appropriate donate button to access PayPal. Thank you!
This Microsoft Word Help & Microsoft Word Tips page is the fifth and final in a series of tips pages written to show how to apply and use the ribbon control attributes to define, modify and display control images and labels. See the Word Help & Tips Index for links to the other pages in this series.
In this tips page we look at a work-a-round for overcoming the difficulty in accessing images stored in the document's data store customUI\images when using the getImage attribute, discussed in the previous tips page.
Remember the advantage of using the data store for custom images, is that the data store is transportable with the document to other users. You don't have to deal with providing the images as separate files or be concerned if the user puts them in the correct directory.
The illustration below shows two views of a custom ribbon tab that I created for this tips page. One shows the image and label for a toggleButton control in the toggled (or pressed state) and the other shows those same controls in the un-pressed state. You can download the demonstration document used to create this pages which contains the associated ribbon, custom XML and VBA callbacks using this link: Ribbon Images & Labels Part V
As in the example in used in Part IV, I used the Custom UI Editor to store two .PNG type image files in the document's OpenXML Format data store customUI\images folder.
The problem is there is no way to assign an image file stored in the document's zipped data store as a variable in the LoadImage function. To resolve the problem we can use the onLoad attribute and VBA to perform the following as the ribbon is loaded:
We now have a folder on the users PC which acts as an external source containing the image files stored in the document's data store folder customUI\images. We can access these images using the getImage attribute and a VBA callback.
When the user closes the document we delete the temporary folders.
The methods seems to work reliably well. The only drawback that I have noticed is you will sometimes see the Windows copying file process running briefly as the document loads.
This concludes this tips page and the series. Once again I would like to thank Bob Phillips, Ron de Bruin and Jonathan West for their assistance and support to make these tips pages possible.
That's it! I hope you have found this tips page useful and informative.
Do you want to make a payment for consulting work or donate to help support this site?
PayPal is a safe, easy way to pay online.
Use the appropriate currency "Donate" button to make a payment or donation.