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

后端 未结 2 1936
半阙折子戏
半阙折子戏 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: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...

提交回复
热议问题