Hi there,
I have the following code that needs to execute. Basically, every once in a while, our terminal program encounters an error that makes it so Excel and it can't talk to each other. The only way to fix this is by killing the entire process tree of both terminal and Excel, or restarting the computer. I've written this bit of code in the event it starts happening while someone is using the macro - it checks to see if the two can talk, and if they can't, it just kills both programs.
Obviously, since the last line is:
That's the last thing Excel does before it goes and commits suicide, so I can't have any line after that. Is there any way for me, before hand, to like... launch Excel with a 8 second delay, so that once the kill command executes, Excel re-opens? Or could I write a batch file with delay built in to execute prior to the kill command? I could use Shell to execute that prior to killing Excel, but I'm not sure if that's possible....
I have the following code that needs to execute. Basically, every once in a while, our terminal program encounters an error that makes it so Excel and it can't talk to each other. The only way to fix this is by killing the entire process tree of both terminal and Excel, or restarting the computer. I've written this bit of code in the event it starts happening while someone is using the macro - it checks to see if the two can talk, and if they can't, it just kills both programs.
Code:
If MFTest <> "TEST" Then
I = MsgBox("Excel is not communicating with Mainframe. The macro can attempt to repair this, but in doing so, will need to close Mainframe and Excel - without saving. If you would like to do this, click Yes. Otherwise, click No to save your work, then re-run this when you're ready.", vbYesNo)
If I = vbYes Then
Shell "taskkill /F /IM pcscm.exe", 0
Shell "taskkill /F /IM pcsws.exe", 0
Shell "taskkill /F /IM excel.exe", 0
Else
MsgBox "The macro will now exit. When you are ready, please run the macro again and click Yes - do not manually close down Excel and Mainframe."
Exit Sub
End If
End If
Code:
Shell "taskkill /F /IM excel.exe", 0