I need to save a copy of the worksheet I'm using as a CSV file. I the save name to be the date and users name, I've set up variables to get this information however i keep getting a Run-time error '1004'; Application-defined or object-defined error message and it will not work.
Code I'm using is:
Sub SaveCSV()
rundate = DateTime.Now
runname = Application.UserName
savename = rundate & runname
sfilename = ActiveWorkbook.Path & "\" & savename & ".csv"
ActiveWorkbook.Save
ActiveWorkbook.SaveAs Filename:=sfilename, FileFormat:=xlCSV
Application.DisplayAlerts = True
End Sub
Can anyone point me in the right direction as to what the problem is and how to fix it please?
Bookmarks