5

How do I suppress the dialog that says "Visual Basic macros will be removed if you save the file in this format. Are you sure you want to use this format?" (see picture below).

Essentially, I'm trying to use a macro to save a .xlsm file as an .xslx file?. I've tried all the dialog suppression code I can find and it isn't working.

Here's my code:

Private Sub SaveWithNoMacros()
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    Application.EnableEvents = False
    ActiveWorkbook.SaveAs Filename:="Clean Workbook With No Macros.xlsx", _  
       FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
    Application.EnableEvents = True
    Application.DisplayAlerts = True
    Application.ScreenUpdating = True
 End Sub

Here's the dialog:

Excel Dialog

As you might imagine, I need to convert a lot of workbooks and would prefer not to do this manually.

-D.

4

2 回答 2

7

Application.DisplayAlerts = False是禁用此对话框的正确语句。但是,正如您所经历的,这在 Excel 2011 上不起作用。遗憾的是,当您使用 Excel 2011 时,无法解决这个问题。如果您使用任何其他版本(在 PC 上),它会工作得很好。

于 2013-10-11T23:34:17.310 回答
3

这对我有用

另存为类型:(选择 =>)启用宏的 Excel 工作簿 (*.xlsm)

于 2014-03-15T14:58:37.317 回答