|
いちおう、Win32APIを使う方法も提示しておきます。
Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, _
lPalam As Long) As Long
Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" _
(ByVal hWnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Sub Check_MyBook()
Dim Ret As Long
Ret = EnumWindows(AddressOf Rekkyo, 0&)
End Sub
Function Rekkyo(ByVal hWndX As Long, lParam As Long) As Boolean
Dim Name As String
Dim Leng As Long, Ret As Long
Name = String(250, Chr(0))
Leng = Len(Name)
Ret = GetWindowText(hWndX, Name, Leng)
If Ret <> 0 Then
If Name Like "*BookX.xls*" Then
MsgBox "BookX.xls は開いています", 64
Exit Function
End If
End If
Rekkyo = True
End Function
|
|