|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Inspector.WordEditor always returns nullThe 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 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(). -- Show quoteHide quoteKen Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "Peter O'Dowd (MVP)" <petero@nospam.com> wrote in message news:u$FBDvVvJHA.4476@TK2MSFTNGP02.phx.gbl... > 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 > > > Hi Ken,
Yes it is Outlook 2007. Thanks for the info, I'll investigate :) Cheers Show quoteHide quote "Ken Slovak - [MVP - Outlook]" <kenslo***@mvps.org> wrote in message news:uqlTDscvJHA.4476@TK2MSFTNGP02.phx.gbl... > 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 > > > "Peter O'Dowd (MVP)" <petero@nospam.com> wrote in message > news:u$FBDvVvJHA.4476@TK2MSFTNGP02.phx.gbl... >> 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 >> >> >> > 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 ------ Show quoteHide quote "Peter O'Dowd (MVP)" wrote: > Hi Ken, > Yes it is Outlook 2007. Thanks for the info, I'll investigate :) > Cheers > > --
Other interesting topics
Working with Outlook Contacts from Access
Start macro creating a mail with contact data and autotext Delegate Exporting Contacts using VBA? Copy message body with formatting from Outlook to Word. avoid syncing birthday date to calendar when saving contact Item Outlook confirmation dialog. Printing TIFF/JPG Attachment Show Sender Address in Tooltip or Customized View Importing from Excel with HTML Formatting Redemption Error code 13 while opening addressbook - vbscript |
|||||||||||||||||||||||