Search code examples
excelbatch-filexlsx

Exit program with saving using batch


I m trying to open and exit the xlsx file with saving using batch file. If the opens- works ok, but there are some problems with exit- because I cant save new stuff in file using taskkill command.

 PROGRAMM=2.xlsx
 Start 2.xlsx
 Sleep 30
 TASKKILL /F /IM EXCEL*

Are there any choices to exit from xlsx with saving using batch?


Solution

  • /f
    

    says to force a termination. Without it it's like clicking the close button, it's a request to the program to terminate, the program is free to ignore it.

    With /f the program is not asked to close but is terminated by windows. The program doesn't even know what's happening.

    Set xlBook = GetObject("C:\Users\User\Documents\Super.xls")
    xlBook.Save
    

    Above vbs script opens and save a document.