jase71ds
Board Regular
- Joined
- Oct 23, 2006
- Messages
- 137
- Office Version
- 365
- Platform
- Windows
In another thread I asked about locating and pasting a folder path by using a Windows explorer type dialogue box.
gpeacock gave me this excellent code that works perfectly...
But now, in addition to a folder, I also need the user to locate a file using a Windows explorer type dialogue box. The path of the file that the user locates needs to be pasted into A2.
I had thought I would be able to modify the above code to make finding a file (as opposed to a folder) and pasting the file path into A2 -- but alas, my VBA skills are just not there yet.
Could anyone assist?
Please note: I do not want to actually open the file that the user selects. Only paste the URL path into A2.
gpeacock gave me this excellent code that works perfectly...
Code:
Sub GetFolder()
Dim fdg As FileDialog
Dim ifn As String
With Application
Set fdg = .FileDialog(msoFileDialogFolderPicker)
ifn = .DefaultFilePath & .PathSeparator
End With
With fdg
.InitialFileName = ifn
.Title = "Select a location"
.Show
End With
If fdg.SelectedItems.Count = 0 Then Exit Sub
Range("A1").Value = fdg.SelectedItems(1)
End Sub
But now, in addition to a folder, I also need the user to locate a file using a Windows explorer type dialogue box. The path of the file that the user locates needs to be pasted into A2.
I had thought I would be able to modify the above code to make finding a file (as opposed to a folder) and pasting the file path into A2 -- but alas, my VBA skills are just not there yet.
Could anyone assist?
Please note: I do not want to actually open the file that the user selects. Only paste the URL path into A2.