|
提示のあったコードでテストしましたが、こちらでもすぐにmsgboxがでます。
こんな感じで如何でしょうか。
Declare Function OpenProcess Lib "kernel32" _
(ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, _
ByVal dwProcessId As Long) As Long
Declare Function GetExitCodeProcess Lib "kernel32" _
(ByVal PROCESS As Long, lpExitCode As Long) As Long
Declare Function CloseHandle Lib "kernel32" _
(ByVal hObject As Long) As Long
Sub AP終了まで待機()
Dim PrcsID As Long, Prcs As Long
Dim ExitCode As Long, Rc As Long
Const F_name As String = "C:\Data\ファイル名.txt"
PrcsID = Shell("Notepad.exe " & F_name, vbNormalFocus)
Prcs = OpenProcess(&H400, 1, PrcsID)
Do
Rc = GetExitCodeProcess(Prcs, ExitCode)
DoEvents
Loop While ExitCode = &H103
Rc = CloseHandle(Prcs)
MsgBox "Notepad.exe が、終了しました。", vbInformation
End Sub
|
|