Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Web
Expertise: Beginner
Feb 5, 2003

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 Explicit
Const 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 = Nothing
End Function
Douglas McKirahan
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date