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

excel, vba

Solution

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

Problem

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 to myFile.csv?"` Dialog box. Here is a snippet of my code: ``` currentBook.SaveAs Filename:=fileNameS, FileFormat:=xlCSV, ConflictResolution:=xlLocalSessionChanges currentBook.Close SaveChanges:=False ``` What do I need to add so that I don't get the "Do you want to save the changes to `myFile.csv`?" Dialog box?

Original source

Related problems