|
こんばんは。
似たようなものですが、
Sub test()
Dim ws As Object
Dim cpath As String
With CreateObject("shell.application")
For Each ws In .Windows
cpath = Replace(Replace(Replace(ws.Locationurl, "%20", " "), "file:///", ""), "/", "\")
If Right(cpath, 1) = "\" Then cpath = Left(cpath, Len(cpath) - 1)
If ThisWorkbook.Path = cpath Then
ws.Quit
Exit For
End If
Next
End With
End Sub
>
>Sub test()
> Dim IE As Object
> Dim strPath As String
> strPath = ThisWorkbook.Path
> For Each IE In CreateObject("Shell.Application").Windows
> If TypeName(IE.document) = "IShellFolderViewDual2" Then
' これ IShellFolderViewDual 2が入りました?
> If IE.document.Folder.Items.Item.Path = strPath Then
> IE.Quit
> End If
> End If
> Next
>End Sub
それとルートだとIE.document.Folder.Items.Item.Path には、
最後に\が付くそうですよ!!
|
|