Can't get the ID of execution starting more than one Excel Document using Process.Start

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
This is simple to explain, i need to track the process id from the files I execute. So lets look at the code.<br/>
For this example just create 2 files in the C: and call it 1.xlsx and 2.xlsx<br/>
Now open the firts file ...
<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small


<span style="font-family:Consolas; color:#0000ff; font-size:x-small
<span style="font-family:Consolas; color:#0000ff; font-size:x-small
<span style="font-family:Consolas; color:#0000ff; font-size:x-small
<pre>Dim objFileExecute As New System.Diagnostics.Process
objFileExecute = Process.Start("C:1.xlsx")
MsgBox(objFileExecute.Id)2[/code]
<span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small








<span style="font-size:xx-small This call is sucessfull, and the message box show foe example the ID 6000 ... now we call a second Process.Start with the second file WITHOUT CLOSING THE EXCEL that opens file 1
<span style="font-size:xx-small
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; Dim objFileExecute <span style="color:Blue; As <span style="color:Blue; New System.Diagnostics.Process
objFileExecute = Process.Start(<span style="color:#A31515; "C:1.xlsx")
MsgBox(objFileExecute.Id)
[/code]
At this point you get an error telling refering the Object ... so using Sysinternals FileExplorer you can see that Excel 2007 just uses ONE thread to handle both files so im guessing that the second call cant be asociated because the app its already
runing.
<span style="font-size:xx-small The question is ... how I can get the Process.Id from several Excel files ?
<span style="font-size:xx-small <span style="font-size:xx-small Thank you, and <span id="x_result_box" lang="en <span title="Haz clic para obtener otras posibles traducciones any
<span title="Haz clic para obtener otras posibles traducciones help <span title="Haz clic para obtener otras posibles traducciones
will be <span title="Haz clic para obtener otras posibles traducciones gratefully
<span title="Haz clic para obtener otras posibles traducciones accepted : )


View the full article
 
Back
Top