For VBA, the modFileDialogVBA includes a VBA_FileDialog_GetFolder function which avoids the use of Windows API calls and is simpler to use though it has fewer features.
Procedure Name | Type | Description |
(Declarations) | Declarations | Declarations and private variables for the modBrowseForFolder module. |
BrowseForFolder | Procedure | Prompts the user for the location of an existing folder (directory) but does not support a starting folder. |
BrowseForFolderWithDefault | Procedure | Prompts the user for the location of an existing directory. Uses call back routine to support the selection of an initial folder. |
BrowseCallbackProc64 | Procedure | Callback routine for the folder browser dialog to support the selection of an initial folder (64-bit version). |
BrowseCallbackProc | Procedure | Callback routine for the folder browser dialog to support the selection of an initial folder (32-bit version). |
AddrOfPointer64 | Procedure | Callback routine to return the value of an AddressOf operator because it can't be assigned directly (64-bit version). |
AddrOfPointer | Procedure | Callback routine to return the value of an AddressOf operator because it can't be assigned directly (32-bit version). |
GetFilePath | Procedure | Get the path part of a string that represents a file. Does not work if the string is a folder. |
IsFolder | Procedure | Determine if a folder exists as specified from a drive letter (e.g. C:\Folder). This procedure is identical to DirectoryExists, but provided if you prefer to use Folder rather than Directory. |
' Example of modBrowseForFolder ' ' To use this example, create a new module and paste this code into it. ' Then run the procedure by putting the cursor in the procedure and pressing: ' F5 to run it, or ' F8 to step through it line-by-line (see the Debug menu for more options) Private Sub Example_modBrowseForFolder() ' Comments: Example of using the modBrowseForFolder module to launch the Windows Browse for Folder dialog to select ' an existing folder and/or create a new folder in VB6 and VBA with 32 and 64 bit Windows API calls. Dim strFolder As String ' Select an existing folder strFolder = BrowseForFolder(0, "Select an existing folder") MsgBox "Selected existing folder: " & strFolder ' Select a folder with option to create a new one strFolder = BrowseForFolder(0, "Select an existing folder or create a new one", True) MsgBox "Selected an existing or new folder: " & strFolder ' Select an existing folder defaulting to the previously selected folder, but not create a new one strFolder = BrowseForFolderWithDefault(0, "Select a folder starting with a specified folder", False, strFolder) MsgBox "Selected existing folder with previously selected folder as the default: " & strFolder ' Select an existing folder defaulting to the previously selected folder and allow creating a new one strFolder = BrowseForFolderWithDefault(0, "Select a folder starting with a specified folder", True, strFolder) MsgBox "Selected existing or new folder with previously selected folder as the default: " & strFolder End Sub
The source code in Total Visual Sourcebook includes modules and classes for Microsoft Access, Visual Basic 6 (VB6), and Visual Basic for Applications (VBA) developers. Easily add this professionally written, tested, and documented royalty-free code into your applications to simplify your application development efforts.
Total Visual SourceBook is written for the needs of a developer using a source code library covering the many challenges you face. Countless developers over the years have told us they learned some or much of their development skills and tricks from our code. You can too!
Supports Access/Office 2016, 2013, 2010 and 2007, and Visual Basic 6.0!
"The code is exactly how I would like to write code and the algorithms used are very efficient and well-documented."
Van T. Dinh, Microsoft MVP