Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Creates and returns a Folder object for the specified folder.
Syntax
retVal = Shell.NameSpace(
  vDir
)
Shell.NameSpace( _
  ByVal vDir As Variant _
) As Folder
Parameters
- 
vDir [in]
 - 
Type: Variant
The folder for which to create the Folder object. This 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 Visual Basic, but not in VBScript or JScript. In those cases, the numeric values must be used in their place.
 
Return value
JScript
Type: Folder**
Object reference to the Folder object for the specified folder. If the folder is not successfully created, this value returns null.
VB
Type: Folder**
Object reference to the Folder object for the specified folder. If the folder is not successfully created, this value returns null.
Examples
The following example shows NameSpace in use. Proper usage is shown for JScript, VBScript, and Visual Basic.
JScript:
<script language="JScript">
    function fnShellNameSpaceJ()
    {
        var objShell = new ActiveXObject("shell.application");
        var objFolder;
        var ssfWINDOWS = 36
        
        objFolder = objShell.NameSpace(ssfWINDOWS);
        if (objFolder != null)
        {
            alert(objFolder.Title);
        }
    }
</script>
VBScript:
<script language="VBScript">
    function fnShellNameSpaceVB()
        dim objShell
        dim objFolder
        
        set objShell = CreateObject("shell.application")
        set objFolder = objShell.NameSpace("C:\\")
        if (not objFolder is nothing) then
            alert(objFolder.Title)
        end if
        set objFolder = nothing
        set objShell = nothing
    end function
 </script>
Visual Basic:
Private Sub fnShellNameSpaceVB()
    Dim objShell  As Shell
    Dim objFolder As Folder
    Set objShell = New Shell
    Set objFolder = objShell.NameSpace(ssfPERSONAL)
    If (Not objFolder Is Nothing) Then
        Debug.Print objFolder.Title
    End If
    Set objFolder = Nothing
    Set objShell = Nothing
End Sub
Requirements
| Requirement | Value | 
|---|---|
| Minimum supported client | 
Windows 2000 Professional, Windows XP [desktop apps only] | 
| Minimum supported server | 
Windows 2000 Server [desktop apps only] | 
| Header | 
  | 
| IDL | 
  | 
| DLL | 
  |