Hello,
I am creating a button... when clicked it will pull up the Windows File Browser.... and let the user select a file.
This part I can do. My problem is that I need it to save to a directory I set (It will be the same directory every time)
How can i get it to save with the original file name to this directory \\server\share
Say a user... Clicks the button.... points to a file c:\test.txt.. when he clicks ok.... how can I get it to save to \\server\share\test.txt... (The file name will be different every time... Path will be the same)
Code:
Private Sub btUploadDoc_Click()
'First, let the user select the file
Dim sourcePath As String
Dim fd As Office.FileDialog
Set fd = Application.FileDialog(MsoFileDialogType.msoFileDialogFilePicker)
With fd
.Title = "Please select file to upload"
' Show the dialog and retrieve the final path selected by the user
.Filters.Clear
.Filters.Add "All Files", "*.*"
.AllowMultiSelect = False
If .Show = True Then
sourcePath = .SelectedItems(1)
Else
Exit Sub
End If
End With
Set fd = Nothing
'Now, do the upload and save the details in the Document table
FileCopy sourcePath, DestPath
End Sub
I need to make this line
Code:
FileCopy sourcePath, DestPath
Take the source file... keeping source name... prefix it with \\server\share...
so basically when users upload files it will look like
\\server\share\Test.pdf
\\server\share\Notes.docx