Batch file backup and close excel

Hello, I need to close an Excel file and save it at the same time, but in a batch file. I've tried a lot of things but nothing works. Could someone help me? Everything I find, 'taskkill', is not what I want. I really want to do a 'save' and a 'close'. I can always do the 'save' in an Excel event: 'Before close', but for that, the batch file needs to close 'Excel'. If that doesn't work, does anyone know another way to do this?

Thanks for your help!

1 answer

  • Votes
  • Date
  • Descending date
  1. Hello,

    In ThisWorkbook, put:

    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    ThisWorkbook.Save
    Application.Quit
    End Sub

    Daniel