Sub Sample()
On Error GoTo Err
Dim AppID As Long
Dim winnow As Long
Dim twPath As String
twPath = ThisWorkbook.Path 'コードが記載してあるExcelファイルがあるパスを指定
winnow = vbNormalFocus 'ウィンドウの指定【vbNormalFocus】の場合はウィンドウにフォーカスが移動する設定
AppID = Shell("explorer.exe " & twPath, winnow) 'エクスプローラーを起動
Exit Sub
Err: 'プログラムが見つからなかった場合
If Err > 0 Then
MsgBox "起動に失敗しました"
End If
End Sub
コメントを残す