Open word document without showing in task bar
I try to use Microsoft Word 10.0 Object Library to open doc file, I not want to display word application on the screen, but it show on the task bar each time . Below is my code,How to fix it?
Thanks.
Object objFalse = false;
Object objTrue = true;
object missing = System.Reflection.Missing.Value;
object emptyData = String.Empty;
Word.Application wordApp = new Word.Application();
Word.Document doc = new Word.Document();
wordApp.Visible = false;
wordApp.WindowState = Word.WdWindowState.wdWindowStateMinimize;
try
{
foreach (String fileName in fileNames)
{
Object objFileName = fileName;
doc = wordApp.Documents.Open(ref objFileName, ref objFalse, ref objTrue,
ref objFalse, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref objFalse,
ref missing, ref missing, ref missing);
wordApp.Visible = false;
wordApp.WindowState = Word.WdWindowState.wdWindowStateMinimize;
doc.ActiveWindow.Selection.WholeStory();
doc.ActiveWindow.Selection.Copy();
IDataObject data = Clipboard.GetDataObject();
this.wordText += data.GetData(DataFormats.Text).ToString();
Clipboard.SetDataObject(String.Empty);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
wordApp.Documents.Close(ref objFalse, ref missing, ref missing);
wordApp.Application.Quit(ref objFalse, ref missing, ref missing);
}
}