Refresh excel workbook from command line

I have an excel workbook in which there is data from multiple text files.
The text files are created in a .bat script.

I would like to refresh the workbook in the script right after creating the files.
Does anyone know a command that can do that?

Thanks!

1

2 Answers

For command line refresh (scheduled by Windows task scheduler) I ended up using this open source application: . Note that Excel needs to be installed on client for this to work.

You can specify what to update, for example "macros", "pivot tables", "Queries" or simply "all".

Together with this nice tool "WasFile" from you can check the age to avoid unnecessary excel-refreshes.

For example, a batch file:

set file1="c:\Tmp\refreshMe.xlsx"
ECHO.
echo ----- %File1% -----------------------------
C:\Test\WasFile.exe %file1% modified not after today-1
if %errorlevel%==0 (echo TRUE: Older than
Goto Next1
)
if %errorlevel%==1 (
echo FALSE: Not older
goto Skip1
)
if %errorlevel%==255 (
Echo ERROR
goto Error
)
:Next1
Echo ### Update START ....
C:\test\ExcelRefresh.exe -d -a -f %file1%
Echo ### Update END ....
echo.

I don't think excel has CLI, but you can use VBS - there is example of importing data from excel spreadsheet using vbs: but it's possible to do this in reverse direction too.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like