之前使用过一种方法,很简单,在VB6 或 VBA 中均可使用,代码如下:
* 但有一个前提条件,因使用到 Shell32.DLL ,故必须先引用 "Microsoft Shell Controls And Automation" 才可以正常使用。
Dim objShell As New Shell32.Shell
Dim oFd As Shell32.Folder2
Set oFd = objShell.BrowseForFolder(Me.Hwnd, "Please choice the folder include target excel files.", 16 + 64)
If Not oFd Is Nothing Then
txtFolder.Text = IIf(Right(oFd.Self.Path, 1) = "/", oFd.Self.Path, oFd.Self.Path & "/")
Else
Exit Sub
End If