Batch File Script Needed for running Excel

Hello,

I want to create a batch file that will run a .dqy file in excel and save.

My problem is when I run the script I have, it opens the file in excel but the query takes a few seconds to run so the new saved file gets created with no data before the query runs.

"C:\Program Files\Microsoft Office\Office\Excel.exe" "C:\CurrentDietOrders.dqy"  > C:\SNH_CurrentDietOrders.xls

I tried a pause command but that doesn't seem to work. All I want to do is run the dqy file and save it in a directory for a department to retrieve.

Help,
Michele
mmemonAsked:
Who is Participating?
 
Shift-3Commented:
I believe the problem isn't with the delay in running the query.  It is that redirection (>) only captures the output of the command itself, which in this case is blank.  To get Excel to save a whole new sheet you will need a different approach.

One I think would work would be to create a new spreadsheet with an auto-run macro that will open the .dgy file, save it under the desired name, and then close Excel.  Most of the steps can probably be captured by going to Tools|Macro|Record New Macro.

Instructions on making the macro auto-run are here: http://www.ozgrid.com/VBA/auto-run-macros.htm
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.