excel - How to save workbook to a new location without saving changes in the old one
问题描述
Is it possible to SaveAs workbook in to a new location with macros enabled(.xlsm) without having the changes saved in old one.
In example i open original workbook, create a new sheet, then macro would save it to a new location without changing original file, so if i were to open the original file again later it is without the new sheet created before. All help is much appriciated
I am using this code to save a file, but it also saves changes in the original file.
Dim path As String
Dim name As String
path = Application.ActiveWorkbook.path
name = Replace(ActiveWorkbook.name, ".xlsm", "")
Application.ActiveWorkbook.SaveAs Filename:=path & "\" & name & "_spreadcell", FileFormat:=52
My plans for future are to import sheets from another workbook and then save this new file to opened workbook location and not save changes in the original file. So if something gets messed up, the user could still use the original file again to import and create new workbook.
Best regards
解决方案
As i commented before:
That's basically what SaveAs does. It Saves File A as File B and opens File B afterwards without saving changes to File A. There's also SaveCopyAs, which saves a copy of File A as File B, but keeps File A open.
推荐阅读
- kubernetes - 如何在整个 pod 生命周期中保持进程运行?
- mongodb - Brew 更新列表中的 mongodb 服务错误消息
- python - 如何在 Jupyter 笔记本中更改 Python 版本?
- python - 如何在列表中打印唯一值?
- javascript - script.js:12 未捕获的类型错误:无法读取 null 的属性“currentTime”
- sql - Laravel Sql 软件
- java - 如何用 mybatis 映射 JSON_ARRAYAGG 结果
- java - 如何扩展java类中的所有变量
- git - 删除为多个存储库创建的单个 git 分支
- python-3.x - 在响应中将 lxml etree 作为 svg 发送