Is there a way to open a Windows Explorer window from a vba form, navigate to a specific file and select it so that the file name is placed in a text box?
Press Windows key + E to open File Explorer. Press Tab until you're in the section of the window containing the files or folders you want to select. Use the arrow keys to move to the file or folder you want to select.
Using the Shift and Left Mouse Key Step 1: Launch File Explorer. Step 2: Open the File Folder containing the files to be selected. Step 3: Select any of the files that you need by clicking on it. Step 4: Hold down the Shift key on your keyboard.
By default, File Explorer opens to Quick Access. If you'd rather have File Explorer open to This PC, go to the View tab and then select Options. In the Open File Explorer to list, select This PC, and then select Apply.
To open File Explorer, click the File Explorer icon on the taskbar, or double-click any folder on your desktop. A new File Explorer window will appear. Now you're ready to start working with your files and folders. From File Explorer, double-click a folder to open it.
Check out this snippet:
Private Sub openDialog() Dim fd As Office.FileDialog Set fd = Application.FileDialog(msoFileDialogFilePicker) With fd .AllowMultiSelect = False ' Set the title of the dialog box. .Title = "Please select the file." ' Clear out the current filters, and add our own. .Filters.Clear .Filters.Add "Excel 2003", "*.xls" .Filters.Add "All Files", "*.*" ' Show the dialog box. If the .Show method returns True, the ' user picked at least one file. If the .Show method returns ' False, the user clicked Cancel. If .Show = True Then txtFileName = .SelectedItems(1) 'replace txtFileName with your textbox End If End With End Sub
I think this is what you are asking for.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With