I am trying to create a button and related text box that allows a user to click, open the standard Windows File Dialog Box and populate the text box with the selected file path, which will then be a hyperlink.
I can get the button to open the File Dialog Box, but when I close it returns "FileDialog(mso FileDialogFileP icker)" instead of the actual file path. Any advice? The code I am using is:
I can get the button to open the File Dialog Box, but when I close it returns "FileDialog(mso FileDialogFileP icker)" instead of the actual file path. Any advice? The code I am using is:
Code:
Private Sub cmdFileDialog_Click() ' This requires a reference to the Microsoft Office 11.0 Object Library. Dim fDialog As Office.FileDialog Dim varFile As Variant ' Set up the File dialog box. Set fDialog = Application.FileDialog(msoFileDialogFilePicker) With fDialog ' Allow the user to make multiple selections in the dialog box. .AllowMultiSelect = False ' Clear out the current filters, and then add your own. .Filters.Clear .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 Me.FileLink = .Item Else MsgBox "You clicked Cancel in the file dialog box." End If End With End Sub
Comment