HI
can help please>>>>
I have a click button in form
I need this button to function if a same file name exist to cancel
else
to copy to other place
code :
thank you
can help please>>>>
I have a click button in form
I need this button to function if a same file name exist to cancel
else
to copy to other place
code :
Private Sub Command130_Click()
Dim CopyDialog As Office.FileDialog
Dim SourceFile As Variant
Dim targetFile As Variant
targetFile = "\\ehaf-ned61919\kbj-temp-share\attach\"
ChDir Dir("*.*", vbDirectory)
Set CopyDialog = Application.FileDialog(msoFileDialogFilePicker)
With CopyDialog
.AllowMultiSelect = True
.Title = "Select File"
.Filters.Add "pdf fiiile", "*.pdf"
If .Show = False Then
MsgBox "You canceled"
End If
If Dir(sourcename) = (targetname) Then
MsgBox "same file name is already exist,,please rename and try again !!!"
Else
For Each SourceFile In .SelectedItems
FileCopy SourceFile, targetFile & Mid$(SourceFile, InStrRev(SourceFile, "\"))
MsgBox "??"
Next
End If
End With
End Sub
thank you