Let user select a folder from script (Visual Basic)

Send Us a Sign! (Contact Us!)
Word PDF XPS Text

This little code [gs snippet] will let you to let an end-user to select a folder to pass to the logic to let your script to decide, for example, how to behave or what to do (decided by the programmer, obviously).

On error resume next

SET fso=createobject("scripting.filesystemobject")
SET WshShell=WScript.CreateObject("Shell.Application")
dirPath=WshShell.BrowseForFolder(0, "Select the path", &H4000, "").items().item().path
IF right(dirPath,1)<>"\" THEN
dirPath=dirpath & "\"
END IF
IF dirpath="\" THEN
dirpath="You have to select a folder!"
END IF
msgbox dirpath

NOTE: this [gs script] use the BrowseForFolder [gs method].

SOURCE

LINK

LANGUAGE
ENGLISH

2 thoughts on “Let user select a folder from script (Visual Basic)”

Comments are closed.