
February 23rd, 2012, 10:43 AM
|
|
Registered User
|
|
Join Date: Nov 2009
Location: Hartford, Connecticut, USA
|
|
|
Copy an Excel file adding yesterday's date
I want to copy an excel file and rename it with yesterday's date. Such as test 02-22-12.xlsx
I have most of the code working, but for some reason it names it test 00-22-12.xlsx I don't know why it is using 00 for the month... Maybe a more advanced VBA user can assist. I am using Visual Basic 2010.
Code:
Module test
Sub Main()
'Copy and Rename the report'
My.Computer.FileSystem.CopyFile("C:\Test.xlsx", "C:\Test " & Format(DateAdd("d", -1, Today()), "mm-dd-yy") & ".xlsx", FileIO.UIOption.AllDialogs, FileIO.UICancelOption.DoNothing) End Sub End Module
|