p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   General .NET (http://p2p.wrox.com/forumdisplay.php?f=122)
-   -   process.startinfo opens new instance of process (http://p2p.wrox.com/showthread.php?t=70298)

Anypond August 28th, 2008 05:35 AM

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())
              {
                thisproc.Kill();
               }
         }
  Process.Start(startInfo);

/*--------------------------------------------------------------------*/

 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 ..








All times are GMT -4. The time now is 12:58 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.