简体   繁体   中英

Excel VBA code to SaveAs a specific filename and close the active workbook

我需要在现有子目录的末尾添加什么VBA代码,以将活动工作簿另存为“ finaloutput.xls”,然后在不保存更改的情况下自动关闭工作簿?

You could use something as simple as this, which I put in another workbook and executed from the Tools...Macros menu (Alt+F8) after activating the workbook to be saved.

Public Sub SaveAsAndClose()

    ActiveWorkbook.SaveAs "finaloutput.xls"
    ActiveWorkbook.Close

End Sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM