|
こんばんは。
やっぱり、休み明け・・、ボケてました。
一応、再送です。
でも、これでは 黄金比さんの求めているものと違うかもしれません。
'======================================
Sub main()
Dim bk As Workbook
Set bk = findbk("D:\TESTエリア\testarea\sample.xls")
If Not bk Is Nothing Then
MsgBox bk.Name
Else
MsgBox "not found"
End If
End Sub
'=======================================================
Function findbk(fullpath As String) As Object
On Error Resume Next
dim myarray as variant
Application.EnableEvents = False
myarray = Split(fullpath, "\")
Set findbk = Workbooks(myarray(UBound(myarray)))
If Err.Number <> 0 Then
Err.Clear
Set findbk = GetObject(fullpath)
If findbk.Parent Is Application Then
findbk.Close False
Set findbk = Nothing
End If
End If
Application.EnableEvents = True
End Function
|
|