I am using the MS Word COM API to print Word documents from C#. See below...
internal void PrintWordFileUsingDefaultPrinter(System.IO.FileInfo file)
{
//Open the document.
object fileName = file.FullName;
Document doc = app.Documents.Open(
ref fileName,
ref missing,
ref trueValue,
ref falseValue,
ref missing,
ref missing,
ref missing,
ref missing,
ref missing,
ref missing,
ref missing,
ref missing,
ref missing,
ref missing,
ref missing,
ref missing);
//Send print job to the printer.
doc.PrintOut(
ref trueValue,
ref falseValue,
ref missing,
ref missing,
ref missing,
ref missing,
ref missing,
ref missing,
ref missing,
ref missing,
ref missing,
ref missing,
ref missing,
ref missing,
ref missing,
ref missing,
ref missing,
ref missing);
doc.Close(ref falseValue, ref missing, ref missing);
}
You will see that I finish by calling doc.Close(). However even after calling this Word still locks my file and I am unable to process it further. Any idea how I can force word to release my file?
(Apart from closing the Word process itself? I don't want to do this as I need to print a HUGE number of documents and prefer not to re-open Word every time)