A
Andrew
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(MsoControlType.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.msoButtonIconAndCaption
.Picture = g_imgScaryFace
End With
Anyone has any ideas what's going wrong?
Regards,
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(MsoControlType.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.msoButtonIconAndCaption
.Picture = g_imgScaryFace
End With
Anyone has any ideas what's going wrong?
Regards,