[VBA]
Option Explicit
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
'My default file path is the desktop, so need 2 change it here to C:
Application.DefaultFilePath = "C:\"
'now, if it doesn't already exist, I want to create a folder on the c drive
'labelled with the active workbooks name (but without the .xls)
'I want to save a COPY of the active book to this folder titled
'as: ActiveWorkbook.Name & Date + Time
ActiveWorkbook.SaveCopyAs Filename:=ActiveWorkbook.Name & Date + Time '< this gives an error
'now I want to restore my default file path
Application.DefaultFilePath = "C:\windows\desktop"
End Sub
[/VBA]
[VBA] ActiveWorkbook.SaveCopyAs Filename:=ActiveWorkbook.Name & Date + Time '< this gives an error[/VBA]
Not to jump in or anything, but wouldn't the default Date and Time formats cause a file name syntax issue causeing the error?
In addition to the directory issue..addressed above
alternate"
[VBA]
ActiveWorkbook.SaveCopyAs Filename:=ActiveWorkbook.Name & Format(Date,"mm_dd_yy") & format(Time,"hh_mm")
[/VBA]
Not sure if this error had been resolved. Hope that helps.