Window ' ************************************************
' File:Dialog.vbs (WSH sample in VBScript)
' Author: (c) G. Born
'
' Using the Shell dialog box to select a folder
'************************************************
Option Explicit
' Flags for the options parameter
Const Bif_returnonlyfsdirs = &h0001
Const Bif_dontgobelowdomain = &h0002
Const Bif_statustext = &h0004
Const bif_returnfsancestors = &h0008
Const Bif_editbox = &h0010
Const bif_validate = &h0020
Const Bif_browseforcomputer = &h1000
Const Bif_browseforprinter = &h2000
Const bif_browseincludefiles = &h4000
Dim WSH, Objdlg, OBJF
' Get Application object of the Windows shell.
Set Objdlg = WScript.CreateObject ("Shell.Application")
' Use of the BrowseForFolder method.
' for Instance:set OBJF = Objdlg.browseforfolder _
' (&h0, "Select the folder to copy", &h10, "C:\Born")
Set OBJF = Objdlg.browseforfolder (&h0, _
"Select the folder to copy", _
Bif_editbox + bif_returnonlyfsdirs)
' Here we use the ' the ' the ' the ' the ' Detect '
If Isvalue (OBJF) Then
MsgBox "Selected folder:" & Objf.title
Else
MsgBox "Canceled"
End If
' Here we use TypeName to detect the result.
If InStr (1, TypeName (OBJF), "folder") > 0 Then
MsgBox "Selected folder:" & Objf.title
Else
MsgBox "Canceled"
End If
Function Isvalue (obj)
' Check whether the value has been returned.
Dim tmp
On Error Resume Next
TMP = "" & obj
If Err <> 0 Then
Isvalue = False
Else
Isvalue = True
End If
On Error GoTo 0
End Function
' * * * end
' Save as Xxx.vbs, double-click to run