Closing Excel Application using VBA

前端 未结 8 1198
忘了有多久
忘了有多久 2020-11-29 04:44

I have used the following without success. The active workbook closes, indeed, but the excel window remains open.

Application.ActiveWindow.Close SaveChanges:         


        
8条回答
  •  庸人自扰
    2020-11-29 05:15

    I think your problem is that it's closing the document that calls the macro before sending the command to quit the application.

    Your solution in that case is to not send a command to close the workbook. Instead, you could set the "Saved" state of the workbook to true, which would circumvent any messages about closing an unsaved book. Note: this does not save the workbook; it just makes it look like it's saved.

    ThisWorkbook.Saved = True
    

    and then, right after

    Application.Quit
    

提交回复
热议问题