1.

Solve : Printing a document using a batch file?

Answer»

I need help!!! How can I create a batch file that opens up a document in excel and prints the document to specific printer? Batch code does not generally do Windows. Using the print command on a Excel workbook/worksheet will produce gruesome results.

A batch file could open an Excel workbook but printing it would only be possible with something like AutoIt, where you could design a macro to mimic your mouse as you go about printing the document.

Generally when dealing with Windows applications, you're better off utilizing a Windows script language.


This type of Excel/batch interaction is often very USEFUL. The
general technique for working with such MSOffice FILES is:

1) Create a dummy .XLS file that simply contains an
auto-open VBA macro that IMPORTS your actual Excel file,
prints it, and quits. Suppose the dummy .XLS file is:
C:\SOMEFOLDER\PrintMyFile.XLS

2) Use a batch file with the command:
start /w C:\SOMEFOLDER\PrintMyFile.XLS
which will start up the dummy file and the VBA macro
will do the work.

This process is preferable to simply putting the
auto-open macro in the main data file. If you did that
it would execute every TIME you opened the file. Since
you'll never open the dummy .XLS file directly yourself
you won't run into this problem by working in the way I
suggest.

This technique is easily adapted to far more complex
MSOffice/batch interaction.



Discussion

No Comment Found