VBScript for “ShowOpenDialog”

VBScript for “ShowOpenDialog”

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
See also  Who are the Modern GPU Cloud Providers?

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist