Shell Function Problem
Could someone please help with problem running code below. It works when I specify only 1 filename in the Shell function but when I try a loop, whereby I want Shell to simply be a file opener of file type specified (ie .sim), the system loops endlessly; opening the .exe and presenting a dialogue box from opened executable program "file doesn't exist".
Background: I've many .sim files in a folder that I want to perform an execution using code inside loop below. Once the task for first opened .sim file is complete I want to loop through all remaining .sim files.
Sub Test1()
Dim Foldername As String
Dim Fname As String
Foldername = "C:\Users\path"
If Right(Foldername, 1) <> Application.PathSeparator Then Foldername = Foldername & Application.PathSeparator
Fname = Dir(Foldername & "*.sim")
Do While Len(Fname)
'When I use the following Shell line for a single .sim file in a given folder and without having to define any Dims above it it works (but the one after doesn't).
'Shell "C:\users-apps\path.exe C:\Users\path\filename.sim", vbHide
Shell "C:\users-apps\path.exe, vbHide"
Application.Wait Now + TimeValue("0:00:03")
SendKeys "(%)m"
Application.Wait Now + TimeValue("0:00:01")
SendKeys "{DOWN 13}"
Application.Wait Now + TimeValue("0:00:01")
SendKeys "{ENTER}"
Application.Wait Now + TimeValue("0:00:01")
SendKeys "{ENTER}"
Application.Wait Now + TimeValue("0:00:01")
SendKeys "(^)S"
Application.Wait Now + TimeValue("0:00:01")
SendKeys ("%fx")
Loop
MsgBox "Task Complete!"
End Sub
Recent comments
5 years 36 weeks ago
6 years 22 weeks ago
6 years 34 weeks ago
6 years 37 weeks ago
6 years 38 weeks ago
6 years 43 weeks ago
6 years 52 weeks ago
7 years 2 days ago
7 years 3 days ago
7 years 3 days ago