Process.Start Issue

I have a vb.net program that launches other programs and am using process.start to do this. however, i ran into an issue when i launch an excel file that runs a macro on startup. It waits for the macro to run, before moving on to the next line of code in vb.

Here's my code:

Dim filetoOpen As String
Dim instance As New Process

filetoOpen = "I:\Excel_With_Startup_Macro.xls"

If My.Computer.FileSystem.FileExists(filetoOpen) Then

Dim startinfo As New ProcessStartInfo(filetoOpen)
instance = Process.Start(startinfo)

'the code doesn't move to this point until excel is
'finished running it's macro, i need it to open excel and move on
MsgBox("Stop")

'ive also tried just doing this
'Process.Start(filetoOpen)

'....More Code

End If

Anyone have any ideas?

[1681 byte] By [samirpx] at [2007-12-24]
# 1

Hello,

You could create a Thread in which you will start excel or another program. That way the process.start will be called in a thread while the main thread is moving on.

Richard

Richard78 at 2007-8-31 > top of Msdn Tech,.NET Development,.NET Base Class Library...
# 2
Wild guess: with ProcessStartInfo.UseShellExecute = true (the default), the shell may be waiting for the started program to start pumping messages (mouse cursor changes to arrow with hourglass). Try running it with UseShellExecute = false. You'll need to specify the executable (excel.exe) and the command line argument (filetoOpen).
nobugz at 2007-8-31 > top of Msdn Tech,.NET Development,.NET Base Class Library...

.NET Development

Site Classified