Use something like:
Option Explicit
Sub testIt()
Dim SrcFilename As String, DestFilename As String
SrcFilename = "C:\" & Range("C1").Value
DestFilename = "\\....\" & Range("C1").Value
If Dir(DestFilename) < "" Then
If MsgBox("File " & DestFilename & _
" exists; OK to overwrite", _
vbOKCancel) = vbCancel Then
Exit Sub '<<<<<
End If
End If
FileCopy SrcFilename, DestFilename
End Sub
--
Regards,
Tushar Mehta, MS MVP -- Excel
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions
In article , rvik
says...
mehta,
yeah.. i got it right. I left out the extension .doc in the cell
address. Once i gave the extension, code worked..
Now a rejoinder to the query, if you all don't mind...
Supposing the file already exits in the destination, then i would like
to have a pop displaying something like " file already exists, Do you
want to overwrite? YES / NO"
Thanks
---
Message posted from http://www.ExcelForum.com/