With Application.FileDialog(msoFileDialogFolderPicker) VBA code: List all folders and subfolder names Sub FolderNames()ĭim fso As Object, j As Long, folder1 As Object Click Insert > Module, and paste the following code into the Module Window. Hold down the ALT + F11 keys, and it opens the Microsoft Visual Basic for Applications window.Ģ. If you want to get all the folder names from a specified directory, the following VBA code may help you, please do as this:ġ.