vbs 打开『选择文件夹』对话框

目录

打开 『选择文件夹』对话框,支持指定默认路径

Function SelectFolder( myStartFolder )
	' Version: 0.1.0
	' Updated: 2021-08-07
	
    ' Standard housekeeping
    Dim objFolder, objItem, objShell
    
    ' Custom error handling
    On Error Resume Next
    SelectFolder = ""

    ' Create a dialog object
    Set objShell  = CreateObject( "Shell.Application" )
    Set objFolder = objShell.BrowseForFolder( 0, "Ñ¡ÔñÎļþ¼Ð", 0, myStartFolder )

    ' Return the path of the selected folder
    If IsObject( objfolder ) Then SelectFolder = objFolder.Self.Path

    ' Standard housekeeping
    Set objFolder = Nothing
    Set objshell  = Nothing
    On Error Goto 0
End Function

msgbox SelectFolder("C:\Windows\Desktop")