Link to home
Start Free TrialLog in
Avatar of amrshalaby
amrshalaby

asked on

Custom icon for a macro in Outlook 2010

I've created various macros in Outlook 2010 using VBA.

I've added the ability to execute these macros from the Ribbon by customising the Ribbon to add a new tab, new group and finally new buttons that execute the macros.

Outlook's built-in icons are ok, but I would prefer to use custom-made icons, perhaps created using some other icon graphics program.

Does anyone know of a straightforward way to do this? I'm a java developer so I'm not too familiar with Microsoft's inner workings.

Many thanks for any help.
Avatar of regmigrant
regmigrant
Flag of United Kingdom of Great Britain and Northern Ireland image

The basic principle is to load the custom image using xml:-
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"
  loadImage="GetImage">
<!-- other stuff -->
   <button id="mycode" image="myimg.jpg" />

However the size, type, grouping, callbacks, etc may vary according to how your current customisations are constructed - especially if you are using Com Addins.

Microsoft has a series of developer resources here:-
http://msdn.microsoft.com/en-us/library/aa338202.aspx

and there's an open source UI editing tool at
http://openxmldeveloper.org/blog/b/openxmldeveloper/archive/2009/08/07/7293.aspx
Avatar of amrshalaby
amrshalaby

ASKER

Thank you regmigrant. Sorry about the delay getting back to you.

Would you be able to provide a step by step process to get this to work? I would investigate the links you've provided however I've got a baby on the way and am a bit time-poor.
Been there and understand the problem but without knowing what you are trying to achieve and how what you've already done there's really not a lot more I can add other then the XML strings above, The MS develop guide discusses how those strings work and the UI editing tool would need your code loaded to allow any changes.
Apologies regmigrant, my bad. I'm a java programmer so microsoft is a bit alien to me (besides a few VBA macros painfully put together).

This isn't an add-in. It's a macro put together by going into Outlook 2010's Developer tab and typing in some VBA code into a stored procedure.

If you then right-click on the Ribbon and select "Customise Ribbon", that allows you add a custom button to the Ribbon (perhaps in a new tab and new group) so that you can call this macro. However you are limited as to the icons you can use - basically the internal stock icons.

My question was whether Microsoft Outlook 2010 allows you to customise the Ribbon further by either:

1. Importing a new icon into their stock collection. In that case you can pick that new icon when customising the Ribbon to add to that new button that calls your macro.
2. Importing a new icon in some other way, and assigning it to the new button.
This is not available from the Office UI - You can only choose from the built in images by design (MS wanted to maintain a consistent user experience).

However you can add custom images to the list or use images from disk - the simplest way to do this is to download a custom UI editor as linked above.

the way it works (simplified):-

Non-binary Excel files are stored as Zip archives and named XLM, XLS  etc. To modify the ribbon you open one of these archives and put your changes into xml stream you will find there called customUI. You can add your own pictures from disk or add them into the file itself - which makes it easier to keep your customisations. To make it work you also need VBA code to process the custom image - (this element is handled for you with the internal images).

Rather than try and coach you - its not complicated but its very easy to screw up if you aren't a XML expert (which definitely includes me) - I will point you at a web site that has example code and explanations.
http://www.rondebruin.nl/win/s2/win009.htm

Download the examples and see how they are manipulating the custom images in three different ways, they recommend the Custom UI route but also cover the modification of the XLSM 'archive'  and include all the code necessary to make it work.

Remember that to view what they are doing you most open the XLSM file with an archive program (I use 7zip) and it will reveal the internal structure mentioned in the article

Outlook is more complicated because it doesn't have the archive container so and add-in or the use of Visual Studio is needed to achieve the same goal.
Thank you regmigrant, that's a nice and easy explanation on your part of how you can add custom icons to Excel and very informative.

It does appear that adding custom images to Excel is relatively straightforward (or not, depending on your views!) but in any case definitely doable by following your instructions above.

As Outlook doesn't have an archive container like Excel, you mentioned that either "an add-in or the use of Visual Studio is needed to achieve the same goal".

I take it then that what I'm trying to do is impossible unless I use Visual Studio?
ASKER CERTIFIED SOLUTION
Avatar of regmigrant
regmigrant
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