How to Set a Default Folder Path in Word VBA Folder Picker
Question details
The user needs a Word VBA macro to automatically open a specific directory when launching a folder picker dialog.

- Product
- Microsoft Word
- Device & OS
- not provided
- Scenario
- Writing a VBA macro to select DOCX files from a specific default folder rather than the system's default directory.
- Observed behavior
- The folder picker needs to be configured programmatically to open directly at the specified default path.
Ensure you have the Developer tab enabled in your Word ribbon and have basic familiarity with navigating the Visual Basic Editor (VBE).
Use Application.FileDialog with InitialFileName Property
Use the FileDialog object configured as a folder picker (msoFileDialogFolderPicker) and assign your target directory to its InitialFileName property.
The most reliable way to prompt a user for a folder while starting in a specific directory is using the Application.FileDialog(4) method. The number 4 represents the msoFileDialogFolderPicker constant.
By setting the .InitialFileName property before calling the .Show method, you force the dialog box to navigate directly to your desired path.
Press ALT + F11 to open the Visual Basic Editor in Word, then go to Insert > Module to create a new macro script.
Copy and paste the following code to create a reusable function: Function GetFolder(Optional DefaultPath As String) As String With Application.FileDialog(4) .InitialFileName = DefaultPath If .Show Then GetFolder = .SelectedItems(1) End With End Function
In your main macro, call the newly created function and pass the specific folder path you want to open by default: Sub SelectMyFolder() Dim strInFolder As String strInFolder = GetFolder(DefaultPath:="G:\MyDocs\German\") MsgBox "You selected: " & strInFolder End Sub

Run VBA Macros Seamlessly in WPS Office
You can execute this exact FileDialog VBA code in WPS Writer. WPS Office provides excellent macro support, allowing you to run, edit, and create VBA scripts with a familiar Visual Basic Editor interface.
- 1. Download and Install: Download WPS Office and ensure the VBA module is enabled during or after installation.
- 2. Open WPS Writer: Launch WPS Writer and navigate to the Developer tab on the top ribbon.
- 3. Access the VBA Editor: Click on 'Visual Basic' or 'Macros' to open the code editor.
- 4. Run Your Code: Insert a new module, paste your FileDialog macro code, and run it just as you would in Microsoft Word.

Frequently Asked Questions
Why does my VBA folder picker open in the Documents folder instead of my default path?
If the path assigned to `InitialFileName` is misspelled, lacks proper drive letters, or does not exist on the specific computer running the macro, VBA will ignore the invalid path and safely fall back to the system's default Documents folder.
How do I select a file instead of a folder using VBA?
To select files, change `Application.FileDialog(4)` to `Application.FileDialog(3)`. The number 3 represents the `msoFileDialogFilePicker` constant, which allows users to browse and select individual files rather than directories.
Can I use a network drive path as the default folder in VBA?
Yes, you can use mapped drive letters (like `Z:\Shared\`) or UNC network paths (like `\\ServerName\SharedFolder\`) as the `DefaultPath` string. The user must have active network access to that location for the dialog to open it successfully.
How do I clear the default path so it opens the last used folder?
Simply omit the `InitialFileName` assignment or set it to an empty string `""`. Without a specified initial file name, the FileDialog typically remembers and opens the folder that was last accessed by the user.




