VBA workbooks.Close without being prompted to if the user wants to save?

后端 未结 2 1922
半阙折子戏
半阙折子戏 2020-11-30 13:58

I am writing a VBA program that converts .xls files into .csv files. The problem is that is brings up the \"Do you want to save the changes t

相关标签:
2条回答
  • 2020-11-30 14:11

    Try using ThisWorkbook.Saved = True

            Application.DisplayAlerts = False
            currentBook.SaveAs Filename:=fileNameS, FileFormat:=xlCSV, ConflictResolution:=xlLocalSessionChanges
            currentBook.Saved = True            
            currentBook.Close SaveChanges:=False
            Application.DisplayAlerts = True
    
    0 讨论(0)
  • 2020-11-30 14:29

    This is what I have done in the past and it's worked for me:

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

    You can also try putting the Close before the DisplayAlerts is reset to true...

    0 讨论(0)
提交回复
热议问题