Declarations...

Code
Public Const BIF_RETURNONLYFSDIRS = &H1 'file system folders only
Public Const BIF_BROWSEFORCOMPUTER = &H1000 'allows you to browse for a'computer
Public Const BIF_BROWSEFORPRINTER = &H2000 'browse Printers Folder


Public Type BROWSEINFO
    hOwner As Long 'handle to the window calling this
    pidlRoot As Long 'ID List point to the top most folder, set this to 0
    pszDisplayName As Long 'Buffer used to hold the display name of the folder selected by the user
    lpszTitle As String 'the caption of the browse dialog
    uFlags As Long 'the flags to determine what to browse for
    lpfn As Long 'the address of the callback function, set to Null
    lParam As Long 'a value passed to the callback function
    iImage As Long 'a buffer to hold the index to the image of selected folder
End Type


'API Function Declarations

Public Declare Function SHBrowseForFolder Lib "shell32.dll" Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long
Public Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long




Code
Public Function Dialog_BrowseFolders(pWindow As Form, pTitle As String) As String
'Function
'   Display a dialog for browsing and selecting a folder.
'Return (String)
'   Returns the filespec of the selected folder.
'   If no folder is selected, returns a zero-length string.
'Parameters
'   pWindow (Form) = A reference to the window that owns the window this function displays.
'   pTitle (String) = The title to display on the dialog.
'Version History
'   1.0
'---

'Initiate variables
Dim bi As BROWSEINFO 'structure we will fill later
Dim pIdList As Long 'the return value (pointer to ID List)
Dim strFolder As String 'extracted value from pIdList

'Create buffer large enough to hold folder path
strFolder = String$(255, Chr$(0))

'Populate BROWSEINFO structure
bi.hOwner = pWindow.hwnd 'handle of the calling form
bi.uFlags = BIF_RETURNONLYFSDIRS 'browse only for system folders
bi.pidlRoot = 0
bi.lpszTitle = pTitle & Chr$(0) 'make the specified title a zero-terminated string

'Initial fucntion call to get ID List pointer
pIdList = SHBrowseForFolder(bi)

'Extract file path and return the result
Dialog_BrowseFolders = IIf(SHGetPathFromIDList(ByVal pIdList, ByVal strFolder), Left$(strFolder, InStr(strFolder, Chr$(0)) - 1), "")

End Function


The Captian
Today they call you "crazy". Tomorrow they call you "ahead of your time."
Global Skywatch Learn about Chemtrails - You're breathing them now!
OnlyTheBestHerbs.com World-class supplements
Mercury Talk Why you are sick.
OneUp Domains Domains, Hosting, Email
1-800-358-4278 (U.S. & Canada)