Ever want to use the Common Dialog “ShowOpenDialog” but were frustrated because it required that Visual Studio be installed on each user’s PC?
Here’s an alternative written in VBScript that can be used in WSH scripts or ASP pages.
To test, save as “Browse4.vbs” then double-click it.
Option ExplicitConst cVBS = "BrowseFor.vbs"MsgBox BrowseForFolder("File","Browse a File")MsgBox BrowseForFolder("Folder","Browse a Folder")Function BrowseForFolder(sBFF,sPMT) BrowseForFolder = "" If sBFF <> "Folder" And sBFF <> "File" Then Exit Function '* Dim objSHL Set objSHL = CreateObject("Shell.Application") Dim objB4F '* On Error Resume Next If sBFF = "Folder" Then Set objB4F = objSHL.BrowseForFolder(&H0,sPMT,&H0031,&H0011) Else Set objB4F = objSHL.BrowseForFolder(&H0,sPMT,&H4031,&H0011) End If BrowseForFolder = objB4F.ParentFolder.ParseName(objB4F.Title).Path If Err.Number <> 0 Then BrowseForFolder = "" '* Set objB4F = Nothing Set objSHL = NothingEnd Function