File not found error when running an exe using Shell function

后端 未结 1 716
感情败类
感情败类 2021-01-24 13:40

I am running a sub from a userform that is supposed to run an exe file, found in the working folder, as follows:

Sub RunProcessor()
    If MsgBox(\"Run simulatio         


        
相关标签:
1条回答
  • 2021-01-24 13:58

    ChDir will only work to change the current directory to another on the same drive - you need to use ChDrive first if you want to switch to a folder on a different drive.

    Better yet, pass the full path to Shell and skip changing the current directory.

    Sub RunProcessor()
        If MsgBox("Run simulation?", vbYesNo) = vbYes Then
            Shell (ThisWorkbook.Path & "\runsims.exe")
        End If
    End Sub
    
    0 讨论(0)
提交回复
热议问题