Link to home
Start Free TrialLog in
Avatar of AL_XResearch
AL_XResearchFlag for United Kingdom of Great Britain and Northern Ireland

asked on

GDI+ error from Office ribbon custom UI editor

I use the Custom UI Editor to edit the office ribbon XML (Click here for link).

When I try to load a ICO file to use as a ribbon icon I get the following error:User generated image
Can anyone tell me how to correct this ? Is there any way around it ?

The environment is Windows 7 Professional 64bit (Service Pack 1). I have tried it on two separate computers and had the same error. I have even tried installing the program again or running under administrator approval mode.
Avatar of Rory Archibald
Rory Archibald
Flag of United Kingdom of Great Britain and Northern Ireland image

Is this with any .ico file, regardless of name and location? (it's generally wise to avoid using image files with spaces in the names)
Avatar of AL_XResearch

ASKER

I have tried it with a number of ICO files from different sources, ones which I have created, ones that have been created by MS and i would think with a variety of names. I will check that there is no space in the filename and get back to you.

Any further thoughts in the mean time ?
Yes it was a filename without spaces or underscores. JPG or PNG gives me no issues.

I find though that PNG files loaded using the editor do not show up on the ribbon though.
It appears that .ico files don't work if they have multiple frames in them (as is often the case). PNG files do work, as I have used them, but there may be an issue with colour depth, I think. I'll do some checking, but I have a feeling that 32bit didn't work for me.
If you could check please. To be honest I don't really care if the file is ICO or PNG - I would just like to create large (in the ribbon sense) and small ribbon images to progress my project.

I assume since the 'large' MS icons can also be used as 'small' buttons that they also have multiple frames (and therefore sizes) as is the normal way to create an ICO file.

If then it is just the editor that has problems with ICO files with multiple frames but the ribbon is fine with them then I am happy (if a little annoyed) to manually edit the XLAM file XML myself in notepad. To that end : do you know the correct adjustments to make to the <Relationship> elements in the 'CustomUI14.xml.rel' file ? I have been searching all over the net and cannot find it.

Many thanks for the timely responses.
I can't find a 32bit file to test on at the moment but have double-checked and 24bit works fine with PNG files. I'll do some testing with the .ICO files shortly.
The multi-frame .ico files seem to work fine - although to be honest I'm not sure what the benefit is of using them; regular images seem to scale pretty well to match the menu item size.

For the test I just added a dummy image file using CustomUI then added the real image file to the zipped file manually and altered the 'CustomUI14.xml.rels' file so that the Target="images/old_file_name.png" pointed to the new .ico file. I left the Id as it was to avoid having to go back and change anything else in the file.
Thats great, thanks. However it does not explain the GDI+ error in the editor.

If I need to manually adjust the XML then : what are the changes I need to make (or a <Relationship> markup example) to get the image stored in the subfolder 'images' to work ? I have looked all over the web and cannot find these.

If you use a PNG then : what is the colour depth allowed ? What is the maximum / recommended size ? I have see some websites that claim the max would be 255 but you seem to have found 50 works. Thew trouble with 50 is it does not give you a lot of canvas to be creative with - unless you start big and scale down.

Your advice much appreciated.
ASKER CERTIFIED SOLUTION
Avatar of Rory Archibald
Rory Archibald
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
<?xml version="1.0" encoding="utf-8" ?>
- <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
  <Relationship Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="images/someIconFile.ico" Id="original_filename" />
  </Relationships>
is exactly what I was looking for. I assume that there are no other amendments to be made to the other XML files ?

I am wondering if the reason I could not get a PNG to show on the ribbon before was the dpi, since I created a new graphic (PNG) of 64x64 192dpi and the icon showed ! I have yet to test loading a larger image and allowing Excel to scale it. Say 400x400 would give you enough room to be creative and create 3d effects / shading.
The id will have to match whatever id you have in the image attribute for your ribbon control in the CustomUI.xml (or CustomUI14.xml) but that's all.
Well it is not that since I am sure the ID in the ribbon and the ID of the loaded image's relationship are the same but I don't know why it didn't work.

When I created a 50x50 icon @ 192 dpi the icon showed fine. Perhaps it was the dpi that was causing the issue
This is exactly what I have been searching for !