M
MTC75
I've created a C# object in a DLL that is loaded in the Excel process.
During the object's initialization, it creates new Excel toolbars and
attempts to place icons on the toolbar.
The code I'm using to get these icons is the following:
sealed private class ConvertImage : System.Windows.Forms.AxHost
{
private ConvertImage()
: base(null)
{
}
/// <summary>
/// Convert System.Drawing.Image to stdole.IPictureDisp.
/// </summary>
/// <param name="image"></param>
/// <returns></returns>
public static stdole.IPictureDisp Convert
(System.Drawing.Image image)
{
return (stdole.IPictureDisp)System.
Windows.Forms.AxHost
.GetIPictureDispFromPicture(image);
}
}
Then a call is made:
IPictureDisp pic = ConvertImage.Convert(image);
However, if this code is executed on a machine with Office 2002, then upon
exiting Excel I get an error window ("An unexpected error has occurred" with
the checkbox to restart Excel). If I comment out the call to
GetIPictureDispFromPicture or if I run on a machine with Office 2003, there
is no problem.
Is there any way around this problem?
During the object's initialization, it creates new Excel toolbars and
attempts to place icons on the toolbar.
The code I'm using to get these icons is the following:
sealed private class ConvertImage : System.Windows.Forms.AxHost
{
private ConvertImage()
: base(null)
{
}
/// <summary>
/// Convert System.Drawing.Image to stdole.IPictureDisp.
/// </summary>
/// <param name="image"></param>
/// <returns></returns>
public static stdole.IPictureDisp Convert
(System.Drawing.Image image)
{
return (stdole.IPictureDisp)System.
Windows.Forms.AxHost
.GetIPictureDispFromPicture(image);
}
}
Then a call is made:
IPictureDisp pic = ConvertImage.Convert(image);
However, if this code is executed on a machine with Office 2002, then upon
exiting Excel I get an error window ("An unexpected error has occurred" with
the checkbox to restart Excel). If I comment out the call to
GetIPictureDispFromPicture or if I run on a machine with Office 2003, there
is no problem.
Is there any way around this problem?