copy file on same folder with diffrent name

bee55

Registered User.
Local time
Yesterday, 23:26
Joined
Oct 27, 2011
Messages
50
Dear All
i have a file on E:\bee55\DailyReport.xls
i have this code

Private Sub CopyFile_Click()
Dim strPath As String
Dim date1 As String

date1 = Format(CDate(Date), "yyyy-mm-dd/ hh:mm:ss") & ".xls"
strpath = "E:\bee55\Daily Report"

FileCopy "E:\bee55\DailyReport.xls", strpath & date1
End Sub

when i excute this code an error occur say: file not found

i try to change the following line:
date1 = Format(CDate(Date), "yyyy-mm-dd/ hh:mm:ss") & ".xls"
to:
date1 = "11/3/1981" & ".xls"
it success and the file was copy with name: DailyReport11/3/1981.xls

my issu is to assign current date to the file name
have any body experience so ??
great thanks,
 
thank you my friends i find out the solution

Private Sub CopyFile_Click()
Dim date1 As String
date1= Format(CDate(Date), ("dd-mm-yyyy"))
FileCopy "E:\musab\book1.xls", "E:\musab\PPlant Daily Report " & date1 & ".xls"
End Sub
 

Users who are viewing this thread

Back
Top Bottom