Using a date string to name a backup

mswantek

Board Regular
Joined
Jul 9, 2002
Messages
123
Hello all!!
I am putting in some code to save a copy of a file to a network drive, for some reason though when I add the date string to the filename and path it bombs!!! Any thoughts? Without the
Code:
& strDate
it saves just fine, but I don't want to have to deal with the "already exists, do you want to overwrite" message........ saving the file with a date then makes it much easier for everyone..... Please help!!!!

Thanks.

Code:
Public Sub backup()
'ActiveWorkbook.Save
                Dim strDate As String
                strDate = Format$(Now, "hh:mm:ss mm-dd-yy")
                Application.ScreenUpdating = False
                On Error GoTo circumv1
ChDir "\\USWRNVS9FSH01\HZS66S$\PPO_forms\backups"

             ActiveWorkbook.SaveAs Filename:="\\USWRNVS9FSH01\HZS66S$\PPO_forms\backups\greensheetdata06backup " & strDate
   
               
               ActiveWorkbook.Close False

circumv1:
                Application.ScreenUpdating = True
End Sub
 

Some videos you may like

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

Watch MrExcel Video

Forum statistics

Threads
1,114,090
Messages
5,545,899
Members
410,711
Latest member
Josh324
Top