そのExcelファイルが開かれているか?をVBAから調べる。
Application.Workbooksで分かるのは、そのExcel.Applicationで開かれているExcelファイルだけです。
そこで、
Dim Path As String
Dim Count As Long
Dim Book As Variant
Path="Excelファイルのフルパス"
Count = Application.Workbooks.Count
Set Book = GetObject(Path)
If Count <> Application.Workbooks.Count Then
Book.Close
Set Book = Nothing
MsgBox "Not Open"
ElseIf Book.Application Is Application Then
MsgBox "Open here"
Else
MsgBox "Open elsewhere"
End If
« そのExcelファイルが開かれているか?をスクリプトから調べる。 | トップページ | DEL *.XLS は危険です! »