Is m_OldEmailCSToolBar still being used and is it a valid object? You can
only add buttons to a CommandBar or CommandBarPopup object, although the
CommandBarPopup buttons are actually being added to the
CommandBarPopup.CommandBar object.
Does it blow up when you set the Picture property? Is this an Explorer or
Inspector button?
For WordMail Inspectors you cannot use the Picture property, you must use
the old PasteFace method with an image put on the clipboard. That's because
Picture takes an IPictureDisp object, which cannot be passed across process
boundaries. As WordMail is Word subclassed by Outlook it runs in its own
separate process and attempting to use Picture there tries to pass the
IPictureDisp object across process boundaries. That forces an exception.
--
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
"Andrew" wrote in message
...
Hello All,
I have an Add-in developed for Outlook 2003. Before this change I was
adding
an image to the ".Picture" property of the button after initially adding
the
button to a popup object. Everything worked fine, however, I decided the
popup object wasn't needed when there was only one associated for a
toolbar.
The buttons where I removed the popup object throws following error when
its
been created:
"
Error HRESULT E_FAIL has been returned from a call to a COM component".
the other buttons that have a popup, work fine. The image being added is
the same everywhere.
This is the class where I create and assign the image to a global
variable:
Public Class clsScaryFace
Inherits System.Windows.Forms.AxHost
Public Sub New()
MyBase.New("59EE46BA-677D-4d20-BF10-8D8067CB8B32")
End Sub
Public Sub GetScaryFace()
Dim scaryFaceImage As Bitmap = Nothing
'Dim scaryFaceMask As Bitmap = Nothing
Try
scaryFaceImage = My.Resources.Scaryface.scaryface
'scaryFaceMask = My.Resources.Scaryface.scary_mask
If (Exists(scaryFaceImage)) Then
g_imgScaryFace = Convert(scaryFaceImage)
'g_imgScaryFaceMask = Convert(scaryFaceMask)
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
scaryFaceImage = Nothing
'scaryFaceMask = Nothing
End Try
End Sub
Private Function Convert(ByVal Image As System.Drawing.Image) As
stdole.IPictureDisp
Convert = CType(GetIPictureDispFromPicture(Image),
stdole.IPictureDisp)
End Function
End Class
This is where I add the button:
m_butOldEmailSyncToCS =
CType(m_OldEmailCSToolBar.Controls.Add(MsoControlT ype.msoControlButton, ,
, ,
Temporary:=True), Office.CommandBarButton)
This is where I set the properties after which it blows up when attempting
to assign the g_imgScaryFace
With m_butOldEmailSyncToCS
.Caption = "Save to CS"
.Visible = True
.Enabled = True
.Style = Microsoft.Office.Core.MsoButtonStyle.msoButtonIcon AndCaption
.Picture = g_imgScaryFace
End With
Anyone has any ideas what's going wrong?
Regards,