我制作的宏将模板工作簿保存为两个单独的文件。每个测试保存一个(Location1,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
答案 0 :(得分:3)
在尝试保存之前添加Application.DisplayAlerts = False
。保存后请记得再回到True。
答案 1 :(得分:1)
ConflictResolution应该是xlLocalSessionChanges,看不到提示
ConflictResolution:=Excel.XlSaveConflictResolution.xlLocalSessionChanges
来自