Hi there, I have created a C#.NET (2.0) Excel 2003 Addin. It creates two commandbars.
One of the command displays the status of several external components in the form of icons.
The C#.NET addin receives information about the status of these components and raises events to update the Excel command bar icons.
The events are received and processed ok, however in the processing code I update the icons that are displayed in the command bar and this does not work although the code does execute correctly.
I am assuming that this is because that GUI update event is not happening on the main Excel GUI thread.
In WinForms I use the PInvoke functions to update the correct GUI thread. However there appears to be no obvious way to do this from Excel when raising events from a C#.NET addin.
How do I update the Excel command bar icons from events coming from my C#.NET addin
Thanks,
Gareth.

How to update Excel CommandBar via Events from C#.NET Addin
remco lubbers
John, thanks for your help. What I am doing is as follows:
private void SetButtonPicture(CommandBarButton button, string key){
try
{
ResourceManager resourceManager = new ResourceManager("EasyExcel.Properties.Resources", Assembly.GetExecutingAssembly());button.Picture =
ConvertImage.Convert((System.Drawing.Image)resourceManager.GetObject(key));button.Mask =
ConvertImage.Convert((System.Drawing.Image)resourceManager.GetObject(key + "Mask"));}
catch (Exception ex){
System.Diagnostics.
Trace.WriteLine(ex.Message);}
}
Initially when I call this routine to create the command bar buttons it works fine and all the icons get displayed perfectly.
Later on when an event is fired that then updates a buttons display image by calling the above code again I get this error message:
"Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))"
sjr1170
John, just wondered if you managed to recreate this yet
Many thanks,
Gareth.
AJ787
derohanes
Thank you very much, that would really be appreciated!
Gareth
Regicide
Gareth,
Which method are you using to update the button face. I have an article about using custom button faces:Custom Button Faces in a Managed Code Add-in for the Microsoft Office System
You should take a look at that. In that article, I am using the copyface/pasteface methods, and these work at runtime as I show.
Let me know if this does not help you.
It is helpful to remember that this forum is mainly for issues that directly pertain to the Visual Studio Tools for Office tools per se. So you will be best served by posing this question to a forum or newsgroup wholly dedicated to application-specific issues such as yours. Here is a link to resources that will help you: http://msdn.microsoft.com/office/support/
There you find links to the appropriate newsgroup or forum.
Rock On,
John.
psmukilan
GC, I will try this out this morning and see what I find. If I can repro, then I'll see if I can find a workaround for you.
JOhn.
Marc Solsona
Hi
So are you using a timer to update the Bitmap on a Command Bar every so often - Have you tried using another office application to see if the behaviour follow's I remember having a similar issue but was able to do it first time without a problem. Word was ok I think Excel was the problem, I think we changed the way we did this in the end using a common Resource Manager and initialised this once and then set the picture from the first intialised Resource Manager class.
Regards