Discussion:
Inspector.WordEditor always returns null
(too old to reply)
Peter O'Dowd (MVP)
2009-04-14 23:50:14 UTC
Permalink
I'm writing an Outlook Add-In, using C# in VS 2005. ( not using VSTO) .
The Add-In uses the shim provided my Microsoft for developing add-ins.

Here's a snippet of the code...
Outlook.Inspector oi = MailItem.GetInspector;

Microsoft.Office.Interop.Word.Document doc =
(Microsoft.Office.Interop.Word.Document)oi.WordEditor;

I need to position the cursor at a certain location in a part of message
body I populate when the mail item is created, hence why I need access to
the WordEditor

Any help greatly appreciated...
Thanks
--
Peter O'Dowd
Exchange Server MVP
http://www.blade.net.nz
Ken Slovak - [MVP - Outlook]
2009-04-15 13:05:42 UTC
Permalink
Hi Peter,

Outlook version you want to work with?

In Outlook 2007 I've found that until the first Inspector.Activate() event
fires that IsWordMail() and WordEditor are null. That's especially the case
if you try to get those during NewInspector().
--
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
Post by Peter O'Dowd (MVP)
I'm writing an Outlook Add-In, using C# in VS 2005. ( not using VSTO) .
The Add-In uses the shim provided my Microsoft for developing add-ins.
Here's a snippet of the code...
Outlook.Inspector oi = MailItem.GetInspector;
Microsoft.Office.Interop.Word.Document doc =
(Microsoft.Office.Interop.Word.Document)oi.WordEditor;
I need to position the cursor at a certain location in a part of message
body I populate when the mail item is created, hence why I need access to
the WordEditor
Any help greatly appreciated...
Thanks
--
Peter O'Dowd
Exchange Server MVP
http://www.blade.net.nz
Peter O'Dowd (MVP)
2009-04-16 00:37:11 UTC
Permalink
Hi Ken,
Yes it is Outlook 2007. Thanks for the info, I'll investigate :)
Cheers
--
Peter O'Dowd
Exchange Server MVP
http://www.blade.net.nz
Post by Ken Slovak - [MVP - Outlook]
Hi Peter,
Outlook version you want to work with?
In Outlook 2007 I've found that until the first Inspector.Activate() event
fires that IsWordMail() and WordEditor are null. That's especially the
case if you try to get those during NewInspector().
--
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
Post by Peter O'Dowd (MVP)
I'm writing an Outlook Add-In, using C# in VS 2005. ( not using VSTO) .
The Add-In uses the shim provided my Microsoft for developing add-ins.
Here's a snippet of the code...
Outlook.Inspector oi = MailItem.GetInspector;
Microsoft.Office.Interop.Word.Document doc =
(Microsoft.Office.Interop.Word.Document)oi.WordEditor;
I need to position the cursor at a certain location in a part of message
body I populate when the mail item is created, hence why I need access to
the WordEditor
Any help greatly appreciated...
Thanks
--
Peter O'Dowd
Exchange Server MVP
http://www.blade.net.nz
Paul T (NJ, USA)
2009-05-01 16:21:01 UTC
Permalink
I am having the same problem after the upgrade to 2007 wiht outomation that I
had in place with NewInspector() event... My work-around was the following:

1) Use NewInspector event to set local class variable to the inspector
2) Define the Activate event for the new inspector variable.

Here is my simplified code with the asnwer:

-----

Dim myOlApp As New Outlook.Application
Public WithEvents myOlInspectors As Outlook.Inspectors
Public WithEvents oActiveInsp As Outlook.Inspector

Public Sub Initialize_handler()
Set myOlApp = Application
Set myOlInspectors = myOlApp.Inspectors
End Sub

Private Sub oActiveInsp_Activate()

' your processing code goes here... wordEditor will be defined now.
' I suggest unsetting oActiveInsp once you're done with it, so that it
does not impact performance everytime you focus on this inspector.

set oActiveInsp = nothing

End Sub


Private Sub myOlInspectors_NewInspector(ByVal Inspector As Outlook.Inspector)
Set oActiveInsp = Inspector
End Sub


------
Post by Peter O'Dowd (MVP)
Hi Ken,
Yes it is Outlook 2007. Thanks for the info, I'll investigate :)
Cheers
--
Loading...