'************************************************
'File:Dialog.vbs(WSHsampleinVBScript)
'Author:(c)G.Born
'
'Usingtheshelldialogboxtoselectafolder
'************************************************
OptionExplicit
'Flagsfortheoptionsparameter
ConstBIF_returnonlyfsdirs=&H0001
ConstBIF_dontgobelowdomain=&H0002
ConstBIF_statustext=&H0004
ConstBIF_returnfsancestors=&H0008
ConstBIF_editbox=&H0010
ConstBIF_validate=&H0020
ConstBIF_browseforcomputer=&H1000
ConstBIF_browseforprinter=&H2000
ConstBIF_browseincludefiles=&H4000
Dimwsh,objDlg,objF
'GetApplicationobjectoftheWindowsshell.
SetobjDlg=WScript.CreateObject("Shell.Application")
'UsetheBrowseForFoldermethod.
'Forinstance:SetobjF=objDlg.BrowseForFolder_
'(&H0,"Selectthefoldertocopy",&H10,"C:Born")
SetobjF=objDlg.BrowseForFolder(&H0,_
"Selectthefoldertocopy",_
BIF_editbox+BIF_returnonlyfsdirs)
'Hereweusethefirstmethodtodetecttheresult.
IfIsValue(objF)Then
MsgBox"Selectedfolder:"&objF.Title
Else
MsgBox"Canceled"
EndIf
'HereweuseTypeNametodetecttheresult.
IfInStr(1,TypeName(objF),"Folder")>0Then
MsgBox"Selectedfolder:"&objF.Title
Else
MsgBox"Canceled"
EndIf
FunctionIsValue(obj)
'Checkwhetherthevaluehasbeenreturned.
Dimtmp
OnErrorResumeNext
tmp=""&obj
IfErr<>0Then
IsValue=False
Else
IsValue=True
EndIf
OnErrorGoTo0
EndFunction
'***End