Problems closing inspector when IsWordMail() is true

  • Thread starter Thread starter Krishna
  • Start date Start date
K

Krishna

Hi,
I am writing a plugin to Outlook 2003 using C#.

I am having problems closing the inspector when IsWordMail() returns
true. The code segment in my InspectorClose Event handler is as
follows:

if (myInspector.IsWordMail())
{

object objSaveChanges =
WdSaveOptions.wdDoNotSaveChanges;
object objOrigFormat =
WdOriginalFormat.wdOriginalDocumentFormat;
object objRouteDoc = false;
Microsoft.Office.Interop.Word.Application applWord
= (myInspector.WordEditor as
Microsoft.Office.Interop.Word._Document).Application;
(myInspector.WordEditor as
Microsoft.Office.Interop.Word._Document).Close(ref objSaveChanges, ref
objOrigFormat, ref objRouteDoc);
objSaveChanges = WdSaveOptions.wdDoNotSaveChanges;
objOrigFormat =
WdOriginalFormat.wdOriginalDocumentFormat;
objRouteDoc = false;


applWord.CommandBars[myCommandBar.Index].Delete();
(applWord as
Microsoft.Office.Interop.Word._Application).Quit(ref myMissing, ref
myMissing, ref myMissing);


}
What's happening is that eventually the inspector is closing, but
when-ever i close the inspector, a new email is opened with some crazy
dump as the message body and then everything closes as expected,
automatically. I cannot understand what is happening and why. Can
someone help me with what I am doing wrong. Or, if there is any better
way to do this.
 
I usually just call to close the document object without saving changes
after deleting any controls I created. I then set CustomizationContext.Saved
to whatever I want and that's it.

Quitting Word will slow things down a lot and shouldn't be necessary. It can
run in the background. Closing it will make it re-load again the next time
an email is opened.
 
Thanks Ken.

Your reply gave me confidence to catch my bug.

The actual problem was else-where with my code. It had something to do
with the plug-in I was writing when the user simply clicks a new email
and closes it without doing anything. I was reading the HTML body and
doing some weird things.


As you suggested, I am not quitting word now.

Thanks,
Krishna.

I usually just call to close the document object without saving changes
after deleting any controls I created. I then set CustomizationContext.Saved
to whatever I want and that's it.

Quitting Word will slow things down a lot and shouldn't be necessary. It can
run in the background. Closing it will make it re-load again the next time
an email is opened.




Krishna said:
Hi,
I am writing a plugin to Outlook 2003 using C#.

I am having problems closing the inspector when IsWordMail() returns
true. The code segment in my InspectorClose Event handler is as
follows:

if (myInspector.IsWordMail())
{

object objSaveChanges =
WdSaveOptions.wdDoNotSaveChanges;
object objOrigFormat =
WdOriginalFormat.wdOriginalDocumentFormat;
object objRouteDoc = false;
Microsoft.Office.Interop.Word.Application applWord
= (myInspector.WordEditor as
Microsoft.Office.Interop.Word._Document).Application;
(myInspector.WordEditor as
Microsoft.Office.Interop.Word._Document).Close(ref objSaveChanges, ref
objOrigFormat, ref objRouteDoc);
objSaveChanges = WdSaveOptions.wdDoNotSaveChanges;
objOrigFormat =
WdOriginalFormat.wdOriginalDocumentFormat;
objRouteDoc = false;


applWord.CommandBars[myCommandBar.Index].Delete();
(applWord as
Microsoft.Office.Interop.Word._Application).Quit(ref myMissing, ref
myMissing, ref myMissing);


}
What's happening is that eventually the inspector is closing, but
when-ever i close the inspector, a new email is opened with some crazy
dump as the message body and then everything closes as expected,
automatically. I cannot understand what is happening and why. Can
someone help me with what I am doing wrong. Or, if there is any better
way to do this.
 
Back
Top