Batch file backup and close excel

Anonymous user -  
danielc0 Posted messages 2189 Registration date   Status Member Last intervention   -
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

  1. danielc0 Posted messages 2189 Registration date   Status Member Last intervention   287
     
    Hello,

    In ThisWorkbook, put:

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

    Daniel
    0