Getting the Word Object from Outlook Message

Add-in Express™ Support Service
That's what is more important than anything else

Getting the Word Object from Outlook Message
 
Marc Fisher




Posts: 11
Joined: 2005-05-21
Can someone give me a clue as to how I can get to the word object within and ItemSend procedure.

What I need to do is find out if word is the active editor, and if it is, I need to remove smarttags from the text.

In pseudo code

OnItemSend()
begin
if item.editor is wordeditor then
begin
objEditor := item.editor.object
objEditor.body.removesmarttags
end
end;

Any help would be appreciated

:-)
Posted 21 May, 2005 13:58:06 Top
Dmitry Kostochko


Add-in Express team


Posts: 2740
Joined: 2004-04-05
Hi Mark,

You have choosen the right way, see the code below. Please note the RemoveSmartTags method exists in the Word XP and Word 2003 Object Model only.


procedure TAddInModule.DoItemSend(ASender: TObject; const Item: IDispatch; var Cancel: WordBool);
var
  IMail: _MailItem;
  IDoc: _Document;
begin
  IMail := nil;
  if Assigned(Item) then
    Item.QueryInterface(IID__MailItem, IMail);
  if Assigned(IMail) then
    try
      if IMail.GetInspector.EditorType = olEditorWord then begin
        IDoc := nil;
        IMail.GetInspector.WordEditor.QueryInterface(IID__Document, IDoc);
        if Assigned(IDoc) then
          try
            //...
            //...
          finally
            IDoc := nil;
          end;
      end;
    finally
      IMail := nil;
    end;
end;
Posted 22 May, 2005 06:47:13 Top
Marc Fisher




Posts: 11
Joined: 2005-05-21

Thats great, thanks for the guidance. :)

Marc
Posted 22 May, 2005 13:00:19 Top