Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Sub TestMain()
Dim strFile As String
Dim WSH As Object
Set WSH = CreateObject("WScript.Shell")
'フyァイルのフルパスを指定
strFolda = Range("Q2")
strFile = Cells(2, 16)
strName = strFolda + "\" + strFile
If Dir(strName) = "" Then
MsgBox "ファイルが存在しません。"
Exit Sub
End If
WSH.Run strName, 1
Call key
End Sub
Sub key()
Sleep 500
SendKeys "{ENTER}", True
Sleep 500
SendKeys "y", True
End Sub
< キー操作 >
https://excwlvba.blogspot.com/2013/05/sendkeys.html
< アプリウィンドウアクティブ化 >
https://docs.microsoft.com/ja-jp/office/vba/language/reference/user-interface-help/appactivate-statement
< Shell >
http://officetanaka.net/excel/vba/function/Shell.htm