When using WordMail you cannot use the Picture/Mask properties.
WordMail is a subclassed version of msword.exe used by Outlook as the email
editor. As such it runs in the Word process space and not in the Outlook
process space. Picture and Mask take IPictureDisp objects, which cannot be
passed across process boundaries, therefore the exceptions.
For WordMail 2003 you must use the clipboard and the PasteFace() method of
the button to add an image. Therefore any masking you do must be done on the
clipboard image.
See if that solves your problem.
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm
"Hichem S" wrote in message
...
I am using outlook 2003. When creating a new mail with WordEditor enabled,
an
exception is thrown. I tried to debug and the exception gets thrown (see
code below) when I try to set the picture/mask property of a button.
My buttons are created by my outlook add-in with my word add-in disabled.
If I disable the outlook add-in and enable the word one, the buttons
creation is successful.
Thank you for your help...
Here is how I create my menubar and button :
CommandBar menuBar = context.GetCommandBars().ActiveMenuBar;
int controlCount = menuBar.Controls.Count;
// Add the menu two positions before the last one which is
"Help" (before Help and Windows menus).
CommandBarPopup rootMenu = (CommandBarPopup)
menuBar.Controls.Add(
MsoControlType.msoControlPopup, Missing.Value,
Missing.Value, controlCount - 1, true);
if (rootMenu == null)
{
return null;
}
rootMenu.Caption = "ProductNameMenu";
rootMenu.Tag = NAME_MENU_BAR;
rootMenu.DescriptionText = "ProductName";
rootMenu.OLEUsage = MsoControlOLEUsage.msoControlOLEUsageClient;
rootMenu.TooltipText = "ProductName";
rootMenu.Visible = true;
rootMenu.Enabled = true;
return AddMenuButtons(context, rootMenu);
CommandBarButton myButton = (CommandBarButton)
rootMenu.Controls.Add(MsoControlType.msoControlBut ton, Missing.Value,
Missing.Value, Missing.Value, true);
myButton .Caption = "Caption";
myButton .Style = MsoButtonStyle.msoButtonAutomatic;
myButton .TooltipText = context.GetButtonSuperTip();
myButton .DescriptionText = context.GetButtonSuperTip();
myButton .OLEUsage = MsoControlOLEUsage.msoControlOLEUsageClient;
myButton .Picture = AxHelper.GetIPictureDispFromImage(BitmapAddDocumen t);
myButton .Mask = AxHelper.GetIPictureDispFromImage(BitmapAddDocumen tMask);
myButton .Visible = true;
myButton .Enabled = true;
// This the class that helps to implement GetIPictureDispFromImage
public class AxHelper : AxHost
{
private AxHelper()
: base(null){}
public static IPictureDisp GetIPictureDispFromImage(Image image)
{
return (IPictureDisp)GetIPictureDispFromPicture(image);
}
public new static IPicture GetIPictureFromPicture(Image image)
{
return GetIPictureFromPicture(image);
}
}