View Single Post
  #1 (permalink)  
Old August 28th, 2008, 05:35 AM
Anypond Anypond is offline
Registered User
Join Date: Feb 2007
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default process.startinfo opens new instance of process

Hi i have requirement where in i need to open a word document file and if already any word document is open, the new file should open in the already open word document window
below is my code.

using System.Diagonostics.

ProcessStartInfo startInfo = new ProcessStartInfo();
                startInfo.FileName = "WINWORD.EXE";
                startInfo.Arguments = "c:\myfile.doc";
foreach (Process thisproc in Process.GetProcessesByName("WINWORD"))
           if (!thisproc.CloseMainWindow())


 The above code is opening the file myfile.doc but it is closing all the opened word files and then opening the myfile.doc in a new instance, IF i remove the " process.kill " then its still opening the myfile.doc in a new instance. but my requirement is , lets say file1.doc is already open then when i run my programe this should open myfile.doc in the same instance of file1.doc ..

Reply With Quote