parkerbelt
Active Member
- Joined
- May 23, 2014
- Messages
- 377
I have the following code that I run from an excel spreadsheet and it runs a .exe file, which opens up another excel spreadsheet and does some things. I want the program to run the .exe file and when it is finished, the spreadsheet that it opens will have been activated - at that point, I want the remaining code to run.
The problem that I'm having is that VBA runs the .exe file, but processes the remaining code right afterwards, on the first spreadsheet, and doesn't wait for the .exe to finish. I've been searching the internet and found that people are using ShellAndWait and I've been trying to make that work, but I can't seem to get my syntax correct.
Anyone have any suggestions?
Here's my code:
The problem that I'm having is that VBA runs the .exe file, but processes the remaining code right afterwards, on the first spreadsheet, and doesn't wait for the .exe to finish. I've been searching the internet and found that people are using ShellAndWait and I've been trying to make that work, but I can't seem to get my syntax correct.
Anyone have any suggestions?
Here's my code:
HTML:
Sub Angus() Dim AngusAppPath As String, varProc As Variant
On Error Resume Next
AngusAppPath = "S:\James Jech Stuff\Program 6 - add vba - Copy.exe"
varProc = Shell(AngusAppPath, 1)
Range("A18:P33").Select Selection.Copy Range("A35").Select ActiveSheet.Paste Rows("37:39").Select Application.CutCopyMode = False Selection.Delete Shift:=xlUp Rows("38:40").Select Selection.Delete Shift:=xlUp Rows("39:41").Select Selection.Delete Shift:=xlUp Rows("39:41").Select Range("G39").Activate Selection.Delete Shift:=xlUp Range("A37").Select ActiveCell.FormulaR1C1 = "=R[-31]C+R[-14]C/2" Range("A37").Select Selection.AutoFill Destination:=Range("A37:P37"), Type:=xlFillDefault Range("A37:P37").Select Range("A39").Select ActiveCell.FormulaR1C1 = "=R[-25]C+R[-8]C/2" Range("A39").Select Selection.AutoFill Destination:=Range("A39:L39"), Type:=xlFillDefault Range("A39:L39").Select Range("N31").SelectEnd Sub