Custom Image added to CommandBar Buttons

A

Andrew

Hello All,

I have an add-in developed in Visual Studio 2008, written in VB.Net for
Outlook 2003 that I'm trying to add a custom image to commandbar buttons that
I created. The image displays correctly in every inspector window except when
I select Microsoft Word as the email editor. When that is selected and I open
a New mail, it throws the following error: "Catastrophic failure (Exception
from HRESULT: 0x8000FFFF (E_UNEXPECTED))"

This is happening on my development machine!

The code to add the custom image was also ported to another project for
Outlook 2007 which works flawlessly.

Here is the class where I get the image and store it in a global variable
which I'm adding to the ".Picture" property of button when its created.

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
If (Exists(scaryFaceImage)) Then
g_imgScaryFace = Convert(scaryFaceImage)
End If

Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
scaryFaceImage = 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

I have no idea why this breaks when WordMail is selected as the editor; any
assistance would be greatly appreciated.

Regards
 
K

Ken Slovak - [MVP - Outlook]

..Picture and .Mask take IPictureDisp objects, which cannot be passed across
process boundaries. WordMail 2003 is a subclassed word.exe and so is running
in another process space. You must use .PasteFace for WordMail 2003 button
images. Put the image on the clipboard and .PasteFace will take it from
there.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top