Jacob Vestergaard
Guest
|
Hello,
I am trying to add a picture to a WordEditor-mail in outlook 2003 on the NewInspector event.
This, however, throws an exception when trying to use the .Shapes.AddPicture() method. It seems that the Word-document is not entirely loaded or something, when trying to access it. How to know when it is? This approach works fine when firing it from a button on an Inspector Commandbar, but throws the following exception when used in NewInspector-event:
Server produced an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT))
I am using the following code:
Private Sub adxOutlookEvents_NewInspector(ByVal sender As Object, ByVal inspector As Object, ByVal folderName As String) Handles adxOutlookEvents.NewInspector
Dim insp As Outlook.Inspector = Nothing
Dim mailItem As Outlook.MailItem = Nothing
Try
insp = CType(inspector, Outlook.Inspector)
If insp.EditorType = Outlook.OlEditorType.olEditorWord Then
Dim doc As Word.Document = Nothing
Dim pic As Word.Shape = Nothing
Try
doc = CType(insp.WordEditor, Word.Document)
pic = doc.Shapes.AddPicture("C:image.jpg", False, True, Word.WdShapePosition.wdShapeRight)
Catch ex As Exception
MsgBox("NewInspector >> Error: " & ex.Message)
Finally
pic = Nothing
doc = Nothing
End Try
End If
Catch ex As Exception
ErrHandler("NewInspector", ex)
End Try
End Sub
Thanks in advance,
Jacob S. Vestergaard |
|
Eugene Astafiev
Guest
|
|
Jacob Vestergaard
Guest
|
Hi Eugene,
That approach is not ideal, when Word is set as the editor, because:
1) Modifying the .Htmlbody causes commandbar-flicker.
2) Gmail still doesn't display images attached that way properly (See http://www.add-in-express.com/forum/read.php?FID=5&TID=3945)
3) The approach mentioned above works perfect, when clicking the button (smooth display, correct aligment of mouse and so on), which is why I would like to at least utilize the Word.Document-approach.
I hope you can follow my reasoning. I will try with your suggested approach once more, but I sincerly hope you can help me with the above approach.
Thank you once again,
Jacob |
|
Eugene Astafiev
Guest
|
Hi Jacob,
It seems that the Inspector window is not initialized yet. You cannot use this code in the NewInspector event handler. |
|