17

我正在编写一个将.xls文件转换为.csv文件的 VBA 程序。问题是弹出"Do you want to save the changes to myFile.csv?"对话框。

这是我的代码片段:

currentBook.SaveAs Filename:=fileNameS, FileFormat:=xlCSV, ConflictResolution:=xlLocalSessionChanges    
currentBook.Close SaveChanges:=False

我需要添加什么以免我收到“您要将更改保存到myFile.csv吗?” 对话框?

4

2 回答 2

19

尝试使用ThisWorkbook.Saved = True

        Application.DisplayAlerts = False
        currentBook.SaveAs Filename:=fileNameS, FileFormat:=xlCSV, ConflictResolution:=xlLocalSessionChanges
        currentBook.Saved = True            
        currentBook.Close SaveChanges:=False
        Application.DisplayAlerts = True
于 2012-06-27T08:41:54.250 回答
2

这是我过去所做的,它对我有用:

Application.DisplayAlerts = False
    ActiveWorkbook.SaveAs Filename:=fileNameS, FileFormat:=xlCSV, conflictResolution:=xlLocalSessionChanges
Application.DisplayAlerts = True
ActiveWorkbook.Close False

您也可以尝试在 DisplayAlerts 重置为 true 之前关闭...

于 2012-06-27T07:05:29.000 回答