gpt4 book ai didi

vba - 强制"is"以保存并另存为无宏工作簿

转载 作者:行者123 更新时间:2023-12-04 21:37:32 28 4
gpt4 key购买 nike

我制作的宏将模板工作簿保存为两个单独的文件。每个测试保存一个(位置 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。

关于vba - 强制"is"以保存并另存为无宏工作簿,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31969747/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com