vba 将 *.xlsm 文件另存为 *.xlsx 并抑制弹出窗口

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23175138/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 18:08:07  来源:igfitidea点击:

Save a *.xlsm file as *.xlsx and suppress the pop-up

excelvbaexcel-vba

提问by Mierzen

The current active workbook is a macro-enabled one.

当前活动工作簿是启用宏的工作簿。

After performing some automated data manipulation, I want to save it as a new macro-free workbook (thus .xlsx instead of .xlsm). To do this, I recorded and edited a macro:

执行一些自动数据操作后,我想将它保存为一个新的无宏工作簿(因此 .xlsx 而不是 .xlsm)。为此,我录制并编辑了一个宏:

Dim newFilePath As string
newFileFullName = "C:\List.xlsx"

ActiveWorkbook.SaveAs Filename:=newFileFullName, FileFormat _
:=xlOpenXMLWorkbook, CreateBackup:=False

Workbooks.Open Filename:=newFileFullName
Windows("List.xlsx").Activate

However, whenever I run this macro, a windowkeeps popping up, asking for confirmation that I want to change the file format.

但是,每当我运行此宏时,都会弹出一个窗口,要求确认我要更改文件格式。

How can I suppress this pop-up and default it to "Yes"?

如何抑制此弹出窗口并将其默认为“是”?

回答by Mierzen

Add Application.DisplayAlerts = False

添加 Application.DisplayAlerts = False

Thanks @simoco

谢谢@simoco