Option
Explicit
Sub
Sample()
SelectMultipleFiles
"Z:\temp"
End
Sub
Sub
SelectMultipleFiles(sFolder
As
String
)
Dim
wb
As
WebBrowser
Dim
objExp
As
Shell32.Shell
Set
objExp =
New
Shell32.Shell
objExp.Open sFolder
Do
While
wb
Is
Nothing
:
Set
wb = GetExplorer(sFolder):
Loop
Dim
sFilename
As
String
, bFirst
As
Boolean
sFilename = Dir(sFolder &
"\" & "
*.xlsx")
bFirst =
True
Do
Until
sFilename =
""
Call
wb.document.SelectItem(sFolder & "\" & sFilename, IIf(bFirst, 5&, 1&))
bFirst =
False
sFilename = Dir()
Loop
End
Sub
Function
GetExplorer(sFolder
As
String
)
As
WebBrowser
Dim
objExp
As
New
Shell32.Shell
Dim
wb1
As
WebBrowser
For
Each
wb1
In
objExp.Windows
If
wb1.Name =
"Windows-Explorer"
And
_
LCase(wb1.document.Folder.Self.Path) = LCase(sFolder)
Then
Set
GetExplorer = wb1
End
If
Next
End
Function