DavidAtWork
Registered User.
- Local time
- Today, 22:39
- Joined
- Oct 25, 2011
- Messages
- 699
If you're still having trouble, this is what I use. You must set a reference to Microsoft Office
Put this code into a module:
Function dialogFileBrowse() As String
'##### This function gives the user the facility to browse for a file and to be able to use the path
'##### as a destination.
'##### You must include the Microsoft Office Object Library, go to Tools/References
Dim fp As FileDialog
Dim vrtSelectedItem As Variant
Dim varX As String
'Create a FileDialog object as a File Picker dialog box.
Set fp = Application.FileDialog(msoFileDialogFilePicker)
fp.AllowMultiSelect = True
If fp.Show = -1 Then
'this is the only way I've been able to assign the selected path as a value to string variable
For Each vrtSelectedItem In fp.SelectedItems
varX = vrtSelectedItem
'vrtSelectedItem is a String that contains the file/path of each selected item.
Next vrtSelectedItem
End If
dialogFileBrowse = varX
End Function
This function should be called from where you set the file/path ie myFile=dialogFileBrowse
David
Put this code into a module:
Function dialogFileBrowse() As String
'##### This function gives the user the facility to browse for a file and to be able to use the path
'##### as a destination.
'##### You must include the Microsoft Office Object Library, go to Tools/References
Dim fp As FileDialog
Dim vrtSelectedItem As Variant
Dim varX As String
'Create a FileDialog object as a File Picker dialog box.
Set fp = Application.FileDialog(msoFileDialogFilePicker)
fp.AllowMultiSelect = True
If fp.Show = -1 Then
'this is the only way I've been able to assign the selected path as a value to string variable
For Each vrtSelectedItem In fp.SelectedItems
varX = vrtSelectedItem
'vrtSelectedItem is a String that contains the file/path of each selected item.
Next vrtSelectedItem
End If
dialogFileBrowse = varX
End Function
This function should be called from where you set the file/path ie myFile=dialogFileBrowse
David