Sub Sample6()
Dim ret As Long
With CreateObject("Wscript.Shell")
ret = .Run(CurrentProject.Path & "***.exe", 7, True)
End With
If ret <> 0 Then MsgBox "失敗しました": Exit Sub
End Sub
Dim ret As Long
With CreateObject("Wscript.Shell")
ret = .Run(CurrentProject.Path & "***.exe", 7, True)
End With
If ret <> 0 Then MsgBox "失敗しました": Exit Sub
End Sub
変数にエスケープ文字を付加することはできないので、次のようにしましょう。
Sub Sample6()
Dim ws As Object
On Error GoTo ErrLabel
Set ws = CreateObject("WScript.Shell")
ws.CurrentDirectory = CurrentProject.Path
ws.Run """***.exe""", 7, True
MsgBox "正常に終了しました"
Exit Sub
ErrLabel:
MsgBox "失敗しました"
End Sub
Dim ws As Object
On Error GoTo ErrLabel
Set ws = CreateObject("WScript.Shell")
ws.CurrentDirectory = CurrentProject.Path
ws.Run """***.exe""", 7, True
MsgBox "正常に終了しました"
Exit Sub
ErrLabel:
MsgBox "失敗しました"
End Sub
この記事へのコメント