Hey Everyone..
I'm writing an automated test to determine whether or not rtf files are successfully opened by MS Word. So far I looping through all the rtfs within a given directory and opening them. Later I will have to catch exceptions to generate a report (log the file name that crashed word).
I am processing a large number of files. My application is currently opening a new instance of Word for each file. Can someone tell me how to close Word?
public class LoadRTFDoc
{
private object FileName;
private object ReadOnly;
private object isVisible;
private object Missing;
private ApplicationClass WordApp;
private object Save;
private object OrigFormat;
private object RouteDoc;
public LoadRTFDoc(object filename)
{
this.WordApp = new ApplicationClass();
this.FileName = filename;
ReadOnly = false;
isVisible = true;
Missing = System.Reflection.Missing.Value;
Save = System.Reflection.Missing.Value;
OrigFormat = System.Reflection.Missing.Value;
RouteDoc = System.Reflection.Missing.Value;
}
public void OpenDocument()
{
WordApp.Visible = true;
WordApp.Documents.Open(ref FileName, ref Missing, ref ReadOnly, ref Missing, ref Missing,
ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing,
ref isVisible, ref Missing, ref Missing, ref Missing, ref Missing);
WordApp.Activate();
}
public void CloseDocument()
{
WordApp.Documents.Close(ref Save, ref OrigFormat, ref RouteDoc);
}
}
I am executing the CloseDocument() method after each document is opened. Anyone have some insight for me on this?
Thanks!