Keeping process running after quitting Excel

steztric
05-30-2008, 05:36 AM
Hi guys. I have tried looking around and everywhere I see people are trying to do the opposite of me! :confused:

I have an Excel spreadsheet that has a lot of data in it. When I click a button I export the data as a .csv and run an external program called LRIC.exe. This program does calculations on the data which could take up to a day to complete. For this reason I would like to be able to close Excel in the meantime while the program runs.

The problem is that when I run the shell command, the process is created as a child to Excel, so that if I close Excel, the process terminates. Is there a way to start the process as a sister to Excel so that if I close Excel, it will keep running?

Here is a sample of my code. Assume I have already exported the data as a file called input.csv:

Dim Path As String
Dim Program As String

Path = ThisWorkbook.Path
Program = Path & "\lric.exe input.csv -csv"
Shell(Program, vbNormalFocus)

The program starts to run. When I close Excel, the process terminates undesirably. Any help would be greatly appreciated. :D

Timbo
05-30-2008, 07:42 AM
Welcome to the forum steztric :)

I'm reasonably certain that a shelled process creates a new thread.

I'm interested to see if your export routine terminates its objects correctly; post your code please.

steztric
06-05-2008, 12:48 PM
Hi Timbo. Thanks for the warm welcome!

I apologise, I made a slight mistake in the code sample above. The Shell command returns a double which must be dumped somewhere.

You are indeed right, for some reason, now when I try and run my program, it doesn't seem to have a problem anymore. I can close Excel and it carries on going regardless. I have no idea what changed between when I submitted my post and trying it now :confused:

You wanted some more code. Here is what my program is doing:

Dim temp As Double
Dim answer As VbMsgBoxResult
answer = MsgBox("Power flow, marginal costs and security factors " & _
"will now be calculated." & vbNewLine & "To quit Excel and allow " & _
"the calculations to continue click OK. To cancel the processes " & _
"and return to Excel click Cancel", vbOKCancel, "Request Response")
If answer = vbOK Then
ChDir ThisWorkbook.Path
temp = Shell("lric.exe input.csv -csv", vbNormalFocus)
Application.Quit
End If

Thanks for the interest anyway!!

Steve

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum