强制是保存并另存为宏免费工作簿

Force yes for save over and save as macro free workbook

我制作的宏将模板工作簿保存为两个单独的文件。每个测试保存一个(位置 1、2、3 或 4),然后在另一个宏中使用每个测试的数据。第二个是保留用于备份的原始数据文件。现在的问题是每次我 运行 每个位置的测试和 运行 这个宏时,它都会询问我是否要保存之前的测试。我怎么能不问就告诉它说是。我想将此工作簿另存为无宏工作簿也是如此。我必须在我的代码中放入什么,我应该把它放在哪里?非常感谢任何帮助。 谢谢

已解决代码:

Sub Auto_Open()

   With Range("A30")
   .Value = Time
   .NumberFormat = "h-mm-ss AM/PM"
   End With

    Dim FileName    As String
    Dim FilePath    As String
    Dim FileDate    As String

    MyNote = "Is Cell 'B27' Overview Information" & SavePath & " Location1,2,3,or 4?"

    Answer = MsgBox(MyNote, vbQuestion + vbYesNo)

    If Answer = vbYes Then

        FilePath = "C:\Users\aholiday\Desktop\FRF_Data_Macro_Insert_Test"
        FileName = Sheets("Data").Range("B27").Text

        Application.DisplayAlerts = False

        ThisWorkbook.SaveAs FileName:=FilePath & "\" & FileName

        Dim FileCopyName    As String
        Dim FileCopyPath    As String
        Dim FileTime        As String

        FilePath = "C:\Users\aholiday\Desktop\Backup"
        FileName = Sheets("Data").Range("B27").Text
        FileTime = Sheets("Data").Range("A30").Text


        ThisWorkbook.SaveAs FileName:=FilePath & "\" & FileName & FileTime & ".xlsx", FileFormat:=xlOpenXMLWorkbook

        MsgBox "File was saved!"
        MsgBox "Ready for Next Test, Please Exit."

        Application.DisplayAlerts = True

    Else
       MsgBox "File was not saved, Please Use Location_1,2,3or,4 Durring SIG ATM Test"
    End If

End Sub

在尝试保存之前添加 Application.DisplayAlerts = False。保存后记得转回True。

ConflictResolution 应该是 xlLocalSessionChanges 才能看不到提示

ConflictResolution:=Excel.XlSaveConflictResolution.xlLocalSessionChanges 

来自

How to use workbook.saveas with automatic Overwrite