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

前端 未结 7 1417
旧时难觅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:40

    I was struggling, but the below worked for me finally!

    Dim WB As Workbook
    
    Set WB = Workbooks.Open("\\users\path\Desktop\test.xlsx")
    
    WB.SaveAs fileName:="\\users\path\Desktop\test.xls", _
            FileFormat:=xlExcel8, Password:="", WriteResPassword:="", _
            ReadOnlyRecommended:=False, CreateBackup:=False
    
    0 讨论(0)
提交回复
热议问题