I have a command button on a form. When the user clicks the button I want an explorer window to appear allowing the user to browse to a directory. Then when they have gotten to the directory they want, have the path to that directory, not to a specific file in the directory, appear in a text box on the form. I have the following code in place but it is not doing what I want it to do.
Private Sub cmdClickToLocate_Click()
Dim fDialog As Office.FileDialog
Dim varFile As Variant
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect = False
.Title = "Select the location of this client's pdf files."
.Filters.Add "", "*.*"
If .Show = True Then
' Loop through each file that is selected and then add it to the list box.
For Each varFile In .SelectedItems
Me.txtPDFfilePath = varFile
MsgBox "You clicked Cancel in the file dialog box."