L
LarryE
I want users to be able to select a file using
FileDialog(msoFileDialogFilePicker) and then have that file copied to a
specific location on the users C Drive. I am having a terrible time defining
the file selected to the FileCopy 'soucefile' parameter. It only accepts text
and the file selected needs to be defined as a Variant for the FileDialog
command to work. Below is the code I have written, but I get a Runtime 52
'Bad file name or number' error. Does anyone know how to do this? VBA is
MADDNING!
Dim CopyDialog As Office.filedialog
Dim SourceFile As Variant
ChDir Dir("*.*", vbDirectory)
Set CopyDialog = Application.filedialog(msoFileDialogFilePicker)
With CopyDialog
.AllowMultiSelect = True
.Title = "Select File"
.Filters.Add "Access Databases", "*.accdb"
If .Show = True Then
For Each SourceFile In .SelectedItems
FileCopy SourceFile, "C:\ORCAS Backup\" & SourceFile
Next
End If
End With
End Function
FileDialog(msoFileDialogFilePicker) and then have that file copied to a
specific location on the users C Drive. I am having a terrible time defining
the file selected to the FileCopy 'soucefile' parameter. It only accepts text
and the file selected needs to be defined as a Variant for the FileDialog
command to work. Below is the code I have written, but I get a Runtime 52
'Bad file name or number' error. Does anyone know how to do this? VBA is
MADDNING!
Dim CopyDialog As Office.filedialog
Dim SourceFile As Variant
ChDir Dir("*.*", vbDirectory)
Set CopyDialog = Application.filedialog(msoFileDialogFilePicker)
With CopyDialog
.AllowMultiSelect = True
.Title = "Select File"
.Filters.Add "Access Databases", "*.accdb"
If .Show = True Then
For Each SourceFile In .SelectedItems
FileCopy SourceFile, "C:\ORCAS Backup\" & SourceFile
Next
End If
End With
End Function