locked
How close a open file RRS feed

  • Question

  • Hi All,

    I did a batch file to open a Excel file to another program read some information on it (only works with the excel file open), but I don't know how to close, without kill the program (Excel).

    My batch file:

    ECHO OFF
    CLS
    C:
    CD "C:\Users\username\AppData\Roaming\Real Time Connect\12.0.0.0\Data"
    COPY L-7466062.csv D:\Test\bat\Test.csv
    D:
    cd Test\bat\
    start Test.csv
    timeout /T 15 /NOBREAK

    Thanks in advance.

    Friday, July 31, 2015 8:27 PM

Answers

All replies

  • What is the purpose? Why do you need to open the CSV file? What does "only works with the excel file open" mean? What only works with it open? Why?


    -- Bill Stewart [Bill_Stewart]

    Friday, July 31, 2015 8:30 PM
  • Hi Bill,

    I have an application that need to get some information from a excel file, but this information have been generated by a .CSV file, so I use a function on Excel (LOOKUP) that get those information from a .CSV file, but it's only works if the .CSV file is open.

    So, I create this batch to open the .CSV to Excel can read it, but I don't know how to close it using a batch file.

    This .CSV file is update each 5 min (generated by another application).

    Let me know if I didn't make my self clear to understand. 

    Friday, July 31, 2015 8:53 PM
  • Sorry but I read your statement again and I don't understand what you are trying to say.

    You don't have to open Excel to read a CSV file. A CSV file is a plain-text file with a .CSV extension.

    You can read CSV files directly in PowerShell - we would strongly recommend using PowerShell rather than batch files.


    -- Bill Stewart [Bill_Stewart]

    Friday, July 31, 2015 9:04 PM
  • Anyway, I know that's not easy to understand :-). I only want to know if it's possibles close a file (not the application) using a batch file; I know that I can open it (using start <file>), but I don't know how to close it.
    Monday, August 3, 2015 12:15 PM
  • How to close a file that is open in an application?

    This depends on the application. Some applications expose an automation object model that allows you to close a file it's using.

    For Office applications, this is typically done via VBA.

    This isn't the right forum for VBA questions, though. The right place to ask VBA questions is here:

    https://social.msdn.microsoft.com/Forums/en-US/home?forum=isvvba

    For Excel, you can also ask here:

    https://social.msdn.microsoft.com/Forums/office/en-US/home?forum=exceldev


    -- Bill Stewart [Bill_Stewart]


    • Edited by Bill_Stewart Monday, August 3, 2015 2:21 PM
    • Marked as answer by Andersonlv Monday, August 3, 2015 4:30 PM
    Monday, August 3, 2015 2:21 PM
  • Ok, I'll check there.

    Thanks for your help, Bill.

    • Marked as answer by Andersonlv Monday, August 3, 2015 4:30 PM
    • Unmarked as answer by Andersonlv Monday, August 3, 2015 4:30 PM
    Monday, August 3, 2015 2:23 PM