How to do a “Save As” in vba code, saving my current Excel workbook with datestamp?

前端 未结 7 1432
旧时难觅i
旧时难觅i 2020-12-03 07:35

I have an Excel Workbook that on form button click I want to save a copy of the workbook with the filename being the current date.

I keep trying the the following

7条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-03 08:37

    I successfully use the following method in one file,

    But come up with exactly the same error again... Only the last line come up with error

    Newpath = Mid(ThisWorkbook.FullName, 1, _
     Len(ThisWorkbook.FullName) - Len(ThisWorkbook.Name)) & "\" & "ABC - " & Format(Date, "dd-mm-yyyy") & ".xlsm"
    ThisWorkbook.SaveAs (Newpath)
    

提交回复
热议问题