|
IE7以降なら下記のようなコードに
なるでしょう。
(ThisWorkbook Module)
----------------------------------
'参照設定
' Microsoft Browser Helpers
' Microsoft Shell Controls And Automation
Private Declare Function BringWindowToTop Lib "User32" _
(ByVal hWnd As Long) As Long
Private WithEvents ie As InternetExplorer
Private WithEvents View As ShellFolderView
Public Sub Test()
SetExplorer "C:\"
End Sub
Public Sub SetExplorer(ByVal sPath As Variant)
Const ShellBrowserWindow = _
"{C08AFD90-F2A1-11D1-8455-00A0C91F3880}"
Const CLSID_FOLDER = _
"{EFA24E64-B078-11D0-89E4-00C04FC9E26E}"
Set ie = GetObject("new:" & ShellBrowserWindow)
With ie
.Visible = True
.ShowBrowserBar CLSID_FOLDER, True
.Navigate2 sPath
End With
BringWindowToTop ie.hWnd
End Sub
Private Sub ie_NavigateComplete2 _
(ByVal pDisp As Object, URL As Variant)
Set View = pDisp.Document
End Sub
Private Sub view_SelectionChanged()
Dim e As Object
Dim i As Long
Columns(1).ClearContents
For Each e In View.SelectedItems
i = i + 1
Cells(i, 1).Value = e.Name
Next
End Sub
Private Sub ie_OnQuit()
Set View = Nothing
Set ie = Nothing
End Sub
|
|