Please tell me how to fix the code in c # winforms vs2010 below so that the new word document (oDoc) is created correctly, i.e. if the word application is not yet running, then create a new word, otherwise if it is already running, then create a new document in the already running word application? Now every time you create a word document, another winword.exe process is created.
Word._Application oWord = new Word.Application(); object oMissing = System.Reflection.Missing.Value; object oEndOfDoc = "\\endofdoc"; object oTemplate = @"c:\a3.dot"; oWord.Visible = true; oWord.Application.WindowState = Word.WdWindowState.wdWindowStateMinimize; Word._Document oDoc = oWord.Documents.Add(ref oTemplate, ref oMissing, ref oMissing, ref oMissing); oDoc.ActiveWindow.WindowState = Word.WdWindowState.wdWindowStateMaximize;