.BrowseForFolder

Prompt the user to select a folder.

Syntax 
      .BrowseForFolder(WINDOW_HANDLE, "Window Title", WINDOW_OPTIONS, StartPath)

Key
   WINDOW_HANDLE  This should always be 0

   WINDOW_OPTIONS
         0 = Folders only
     16384 = Browse all files

   StartPath     A drive/folder path or one of the following numeric constants: 
     DESKTOP = 0
     PROGRAMS = 2
     DRIVES = 17
     NETWORK = 18
     NETHOOD = 19
     PROGRAMFILES = 38
     PROGRAMFILESx86 = 48
     WINDOWS = 36

Although you can display files with .BrowseForFolder, the method will only return a folder.

Example

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder(0, "Example", 1, "c:\Programs")
If objFolder Is Nothing Then
Wscript.Quit
End If wscript.Echo "folder: " & objFolder.title & " Path: " & objFolder.self.path

“You affect the world by what you browse” ~ Tim Berners-Lee

Related:

FileSystemObject - Work with Drives, Folders and Files


© Copyright SS64.com 1999-2013
Some rights reserved