我正在编写一个VBA程序,将.xls
个文件转换为.csv
个文件。问题是会出现"Do you want to save the changes to myFile.csv?"
对话框。
以下是我的代码片段:
currentBook.SaveAs Filename:=fileNameS, FileFormat:=xlCSV, ConflictResolution:=xlLocalSessionChanges
currentBook.Close SaveChanges:=False
我需要添加什么,以便我不会收到“您是否要将更改保存到myFile.csv
?”对话框?
答案 0 :(得分:16)
尝试使用ThisWorkbook.Saved = True
Application.DisplayAlerts = False
currentBook.SaveAs Filename:=fileNameS, FileFormat:=xlCSV, ConflictResolution:=xlLocalSessionChanges
currentBook.Saved = True
currentBook.Close SaveChanges:=False
Application.DisplayAlerts = True
答案 1 :(得分:2)
这是我过去所做的,它对我有用:
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:=fileNameS, FileFormat:=xlCSV, conflictResolution:=xlLocalSessionChanges
Application.DisplayAlerts = True
ActiveWorkbook.Close False
您还可以在DisplayAlerts重置为true之前尝试关闭...
答案 2 :(得分:1)
Set XC = NTSGetExcell(True)
XC.Visible = True
XC.Application.DisplayAlerts = False
XC.IgnoreRemoteRequests = True
XC.ActiveWindow.Close False
XC.Quit
Set XC = Nothing