Creates a dialog box that enables the user to select a folder and then returns the selected folder's Folder object.
Syntax
oFolder = Shell.BrowseForFolder(Hwnd, sTitle, iOptions [, vRootFolder])
Parameters
| Hwnd |
Required.
The handle to the parent window of the dialog box. This value can be zero. |
| sTitle |
Required.
A String value that represents the title displayed inside the Browse dialog box. |
| iOptions |
Required.
An Integer value that contains the options for the method. This can be zero or a combination of the values listed under the ulFlags member of the BROWSEINFO structure. |
| vRootFolder |
Optional.
The root folder to use in the dialog box. The user cannot browse higher in the tree than this folder. If this value is not specified, the root folder used in the dialog box is the desktop. This value can be a string that specifies the path of the folder or one of the ShellSpecialFolderConstants values. Note that the constant names found in ShellSpecialFolderConstants are available in Microsoft Visual Basic, but not in Visual Basic Scripting Edition (VBScript) or Microsoft JScript. In those cases, the numeric values must be used in their place. |
Return Value
An object reference to the selected folder's Folder object.
Examples
The following example uses
BrowseForFolder to display a browse window titled "Example" rooted at the Windows folder. Proper usage is shown for JScript, VBScript, and Visual Basic.
JScript:
<script language="JScript">
function fnShellBrowseForFolderJ()
{
var objShell = new ActiveXObject("Shell.Application");
var ssfWINDOWS = 36;
var objFolder;
objFolder = objShell.BrowseForFolder(0, "Example", 0, ssfWINDOWS);
if (objFolder != null)
{
// Add code here.
}
}
</script>
VBScript:
<script language="VBScript">
function fnShellBrowseForFolderVB()
dim objShell
dim ssfWINDOWS
dim objFolder
ssfWINDOWS = 36
set objShell = CreateObject("Shell.Application")
set objFolder = objShell.BrowseForFolder(0, "Example", 0, ssfWINDOWS)
if (not objFolder is nothing) then
'Add code here.
end if
set objFolder = nothing
set objShell = nothing
end function
</script>
Visual Basic:
Private Sub fnShellBrowseForFolderVB()
Dim objShell As Shell
Dim ssfWINDOWS As Long
Dim objFolder As Folder
ssfWINDOWS = 36
Set objShell = New Shell
Set objFolder = objShell.BrowseForFolder(0, "Example", 0, ssfWINDOWS)
If (Not objFolder Is Nothing) Then
'Add code here
End If
Set objFolder = Nothing
Set objShell = Nothing
End Sub
Applies To