PDA

View Full Version : [SOLVED:] Save file with todays date - Format Error



ChrisAcheson
07-10-2017, 09:11 AM
Hi All


My code seems to have broken on the below, in relation to the the word 'format' it worked previously and now has stopped working.


Does anyone know why the below code would now not work, or an alternative suggestion for this below code?

Thanks


ActiveWorkbook.SaveAs Filename:="C:\My Documents\O_S AS OF " & Format(Date, "ddmmyy") & ".xlsx", FileFormat:=51

Leith Ross
07-10-2017, 09:45 AM
Hello Chris,

You can try qualifying the Format statement like this...


ActiveWorkbook.SaveAs Filename:="C:\My Documents\O_S AS OF " & VBA.Format(Date, "ddmmyy") & ".xlsx", FileFormat:=51


If that fails to work, check that you workbook you are trying to save is Not XLSM.

ChrisAcheson
07-10-2017, 09:55 AM
Thats Great - worked a treat Leith. Thank you.

I wonder why it was working before, and only now decided to break.

Leith Ross
07-10-2017, 10:03 AM
Hello Chris,

I have had this issue before and have never been able to identify the cause. I suspect sometimes the workbook becomes corrupted only a little and VBA class references are affected. But, that's only a guess.

ChrisAcheson
07-10-2017, 11:01 AM
Hey Leith.

Yes, exactly the scenario here.

Thanks again for your help.