[英]Save a copy of an excel workbook without macro
I have an Excel 2010 template file with macros that includes the following code:我有一个带有宏的 Excel 2010 模板文件,其中包含以下代码:
ActiveWorkbook.SaveAs Filename:= _
newname, FileFormat:= _
51, CreateBackup:=False
This saves the current workbook as a non-Macro enabled workbook, but then I obviously cannot run the rest of the macros that I need.这会将当前工作簿保存为非启用宏的工作簿,但显然我无法运行我需要的其余宏。
I tried to use我试着用
ActiveWorkbook.SaveCopyAs Filename:= _
newname, FileFormat:= _
51, CreateBackup:=False
This yields a syntax error.这会产生语法错误。 My goal is to save a copy with the new name, so the template file remains unchanged and can be run daily.
我的目标是用新名称保存一个副本,这样模板文件保持不变并且可以每天运行。
try this:尝试这个:
Dim wMacro As Workbook 'workbook you want to save
wMacro.Sheets(Array("Sheet1", "Sheet2", "etc")).Select
wMacro.Sheets(Array("Sheet1", "Sheet2", "etc")).Copy
ActiveWorkbook.SaveAs Filename:= "filename.xlsx", FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
it will create a copy and save.它将创建一个副本并保存。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.