We've got some code that makes use of MS Word in the sense that it makes use of code similar to that which follows :
Word.Application Word_App = new Word.Application();
Word.Document Word_doc = new Word.Document();
Word.Documents Docs = Word_App.Documents;
Word._Document Doc1 = (Word._Document)Word_doc;
.. more code to process the document ...
.. and print it ....
Doc1.PrintOut(ref oTrue, ref oFalse, ref oPrintRange,
ref oMissing, ref oMissing, ref oMissing,
ref oPrintItems, ref oPrintCopies, ref oPrintPages,
ref oPrintPageType, ref oFalse,
ref oTrue, ref oMissing, ref oFalse, ref oMissing,
ref oMissing, ref oMissing, ref oMissing);
// Close the document and Word
Word_App.Visible = false;
// Ensure the document and Word are discarded
try
{
Doc1.Close(ref oFalse, ref oMissing, ref oMissing);
}
catch {}
try
{
Docs.Close(ref oFalse, ref oMissing, ref oMissing);
}
catch {}
try
{
Word_doc.Close(ref oFalse, ref oMissing, ref oMissing);
}
catch {}
try
{
Doc1 = null;
}
catch {}
try
{
Docs = null;
}
catch {}
try
{
Word_doc = null;
}
catch {}
try
{
Word_App = null;
}
catch {}
Try as we might we still find that we have an instance of 'WINWORD.exe' running when we use the 'Task Manager'.
Clearly this is an overhang from what we're doing and we need to prevent it.
Can anyone shed any light on what clean-up step we're overlooking ?
Thanks in advance
Steve
Word.Application Word_App = new Word.Application();
Word.Document Word_doc = new Word.Document();
Word.Documents Docs = Word_App.Documents;
Word._Document Doc1 = (Word._Document)Word_doc;
.. more code to process the document ...
.. and print it ....
Doc1.PrintOut(ref oTrue, ref oFalse, ref oPrintRange,
ref oMissing, ref oMissing, ref oMissing,
ref oPrintItems, ref oPrintCopies, ref oPrintPages,
ref oPrintPageType, ref oFalse,
ref oTrue, ref oMissing, ref oFalse, ref oMissing,
ref oMissing, ref oMissing, ref oMissing);
// Close the document and Word
Word_App.Visible = false;
// Ensure the document and Word are discarded
try
{
Doc1.Close(ref oFalse, ref oMissing, ref oMissing);
}
catch {}
try
{
Docs.Close(ref oFalse, ref oMissing, ref oMissing);
}
catch {}
try
{
Word_doc.Close(ref oFalse, ref oMissing, ref oMissing);
}
catch {}
try
{
Doc1 = null;
}
catch {}
try
{
Docs = null;
}
catch {}
try
{
Word_doc = null;
}
catch {}
try
{
Word_App = null;
}
catch {}
Try as we might we still find that we have an instance of 'WINWORD.exe' running when we use the 'Task Manager'.
Clearly this is an overhang from what we're doing and we need to prevent it.
Can anyone shed any light on what clean-up step we're overlooking ?
Thanks in advance
Steve