+ Reply to Thread
Results 1 to 3 of 3

Batch file won't close opened .xls files and finish routine

  1. #1
    Registered User
    Join Date
    03-06-2022
    Location
    India
    MS-Off Ver
    LTSC Pro Plus 2021
    Posts
    6

    Batch file won't close opened .xls files and finish routine

    I have a simple batch file that opens 2 excel files. One updates new data to the other.

    I want to then close both files, and then delete one of them.

    My bat file will not process the taskkill command as long as the .xls files are open, and nothing I can think of will close or terminate these 2 open xls files.

    How can I terminate open .xls files in a batch routine?

    Here's my .bat >>

    D:\quotes.csv | D:\Data.XLS | Pause |
    taskkill /f /im excel.exe
    Del E:\Box-Download\quotes.csv
    pause

    Thanks!

    Rod

  2. #2
    Forum Expert
    Join Date
    07-06-2004
    Location
    Northern California
    MS-Off Ver
    2K, 2003, 2010, O365
    Posts
    1,475

    Re: Batch file won't close opened .xls files and finish routine

    Does D:\Data.XLS update D:\quotes.csv or vice versa? Meaning, does the XLS file read in values from the CSV file using external reference formulas and save itself, or does the XLS file make changes to the CSV file then save the CSV file? Either way, why not use the XLS file's Workbook_Open event handler?
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    You could also embellish the batch file with
    Please Login or Register  to view this content.
    replacing the 1st pause.

  3. #3
    Registered User
    Join Date
    03-06-2022
    Location
    India
    MS-Off Ver
    LTSC Pro Plus 2021
    Posts
    6

    Re: Batch file won't close opened .xls files and finish routine

    Data.XLS updates Quotes.csv but does NOT save automatically.

    I gave your event handler a try but it would not close and save the files. Or it would hang the batch processing.

    The taskkill command worked by brute force , but it does not save the data after the update.

    Closing AND saving open excel docs seems to be much harder than you'd expect in a command line.

    START D:\data.csv
    START D:\Quotes.XLS
    setlocal enableextensions
    set EXCELAUTOEXIT=on
    D:\quotes.XLS
    D:\data.XLS
    pause
    taskkill /f /im excel.exe
    pause
    del E:\Box-Download\quotes.csv
    CLS

    I'll try your suggestions more thoroughly.

    Many thanks!
    Rod

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Batch job. Open a lot of excel files, delete the same values from each, save, then close
    By greendale in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 11-06-2013, 03:31 PM
  2. [SOLVED] Need to call a batch file when a workbook is opened
    By ianpwilliams in forum Excel Programming / VBA / Macros
    Replies: 31
    Last Post: 07-04-2013, 12:55 AM
  3. [SOLVED] Close ALL Already Opened Files without SAVE
    By eltonlaw in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-17-2012, 03:16 AM
  4. Run a macro only when file is opened via a batch file?
    By dylanemcgregor in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 05-28-2010, 12:17 PM
  5. Use batch file to close workbook?
    By dylanemcgregor in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-23-2009, 12:37 PM
  6. Please help! Want to auto-close opened XML file
    By Zerex71 in forum Excel General
    Replies: 0
    Last Post: 08-02-2006, 11:20 AM
  7. can't close files opened in an excel application??
    By urgent in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-28-2005, 09:05 PM
  8. [SOLVED] Close file and run macro from newly opened file
    By Pradip Jain in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-23-2005, 07:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1