Command line utility to print .doc, .xls, .ppt, .pdf and .txt files

  • Thread starter Thread starter Grod
  • Start date Start date
G

Grod

I am looking for a command line utility that can be used in a batch
file that will print MS Office files (.doc, .xls, .ppt), Adobe .pdf
files and .txt files on Windows 2000 and up.

It should not require any interaction since it would be used in a batch
file. e.g. assuming its called superprint it would be used like this:

superprint myfile.doc
superprint myfile.xls
etc.

Thanks.
 
You're asking a lot. No such animal exists at the moment. There
are some animals individually that will print .doc, pdf, etc. But, you
are asking for ..."Superprint" which recognizes ALL file formats and
will intelligently sort out their individual algorithms for lining up fonts
and using colors, etc. Won't happen. In the first place, most of the
formats you want to deal with were developed for Windows, long
after the death of DOS. And, even if you were considering using a
DOS shell out emulation from Windows, why not wish for a Windows
program in the first place to do what you want?

The closest I can discover to that which you seek might be ...
Quick View Plus .. certainly not freeware, but it recognizes and
prints out all the formats you mentioned. I suppose it might be
able to print several mixed formats in a queue. Dunno how it might
perform being used in a batch file.

Were you intending to find freeware that does this?

==================================
 
Grod said:
I am looking for a command line utility that can be used in a batch
file that will print MS Office files (.doc, .xls, .ppt), Adobe .pdf
files and .txt files on Windows 2000 and up.

It should not require any interaction since it would be used in a
batch file. e.g. assuming its called superprint it would be used
like this:

superprint myfile.doc
superprint myfile.xls
etc.

ClassExec appears to do what you want. It has MS Word as an example, but
should work for most DDE-enabled programs (haven't used it, though):
http://home.wanadoo.nl/fvu/Projects/ClassExec/Web/classExec.htm
 
Yes, I am looking for a freeware program. I am just trying out the classExec
program suggested by someone else. That's the sort of thing I need. It would
be ok if there were separate programs for each of the file types since I could
presumably check the file type and start up the correct program in the batch
file; however, the most convenient would be a single program.

Even though I am primarily looking for freeware I will keep your Quick View
Plus idea around just in case. Thanks for your suggestion.

: You're asking a lot. No such animal exists at the moment. There
: are some animals individually that will print .doc, pdf, etc. But, you
: are asking for ..."Superprint" which recognizes ALL file formats and
: will intelligently sort out their individual algorithms for lining up fonts
: and using colors, etc. Won't happen. In the first place, most of the
: formats you want to deal with were developed for Windows, long
: after the death of DOS. And, even if you were considering using a
: DOS shell out emulation from Windows, why not wish for a Windows
: program in the first place to do what you want?
:
: The closest I can discover to that which you seek might be ...
: Quick View Plus .. certainly not freeware, but it recognizes and
: prints out all the formats you mentioned. I suppose it might be
: able to print several mixed formats in a queue. Dunno how it might
: perform being used in a batch file.
:
: Were you intending to find freeware that does this?
:
: ==================================
: : > I am looking for a command line utility that can be used in a batch
: > file that will print MS Office files (.doc, .xls, .ppt), Adobe .pdf
: > files and .txt files on Windows 2000 and up.
: >
: > It should not require any interaction since it would be used in a batch
: > file. e.g. assuming its called superprint it would be used like this:
: >
: > superprint myfile.doc
: > superprint myfile.xls
: > etc.
: >
: > Thanks.
 
: Grod wrote:
: > I am looking for a command line utility that can be used in a batch
: > file that will print MS Office files (.doc, .xls, .ppt), Adobe .pdf
: > files and .txt files on Windows 2000 and up.
: >
: > It should not require any interaction since it would be used in a
: > batch file. e.g. assuming its called superprint it would be used
: > like this:
: >
: > superprint myfile.doc
: > superprint myfile.xls
: > etc.
:
: ClassExec appears to do what you want. It has MS Word as an example, but
: should work for most DDE-enabled programs (haven't used it, though):
: http://home.wanadoo.nl/fvu/Projects/ClassExec/Web/classExec.htm

Thanks. This seems like a really neat program. I did two tests with
each of a .doc, .xls, .ppt, .pdf and .txt. In the first test I just
tried to start it up from the command line using classExec (of course
I could have just used start but the idea was to test out classExec).
For the second set of tests I tried it with --action print. I don't
actually have a printer installed on my test computer so I regarded
an error message about being unable to print or not finding a printer
as success. All the file types worked for me except Excel. For Excel
it did open Excel but the file never appeared. This test is not
perfect since the error message generally requires one to press ok
whereas in a real run there would be a printer there and no error message.

If anyone does this test on a better test system before I get a chance
please let me know your experience.

The documentation of classExec also provides a wsh script for printing
but I could not get that to reliably work so I am sticking with classExec.

Even though I don't currently have a solution for Excel I don't need
to automatically print many Excel files -- its usually Word, PDF, .txt
or .ppt so provided my tests work out on another computer with an
actual printer this probably solves 95% of my problems. (If anyone
has an Excel-specific solution please let me know.)

I suspect that this program has uses way beyond just printing files
if I knew what the valid possibilities were for the --action argument.
Anyone know where I can find the set of DDE actions that Word,
Excel, Powerpoint, Acrobat and notepad accept?
 
: Grod wrote:
: > I am looking for a command line utility that can be used in a batch
: > file that will print MS Office files (.doc, .xls, .ppt), Adobe .pdf
: > files and .txt files on Windows 2000 and up.
: >
: > It should not require any interaction since it would be used in a
: > batch file. e.g. assuming its called superprint it would be used
: > like this:
: >
: > superprint myfile.doc
: > superprint myfile.xls
: > etc.
:
: ClassExec appears to do what you want. It has MS Word as an example, but
: should work for most DDE-enabled programs (haven't used it, though):
: http://home.wanadoo.nl/fvu/Projects/ClassExec/Web/classExec.htm

Thanks. This seems like a really neat program. I did two tests with
each of a .doc, .xls, .ppt, .pdf and .txt. In the first test I just
tried to start it up from the command line using classExec (of course
I could have just used start but the idea was to test out classExec).
For the second set of tests I tried it with --action print. I don't
actually have a printer installed on my test computer so I regarded
an error message about being unable to print or not finding a printer
as success. All the file types worked for me except Excel. For Excel
it did open Excel but the file never appeared. This test is not
perfect since the error message generally requires one to press ok
whereas in a real run there would be a printer there and no error message.

I have since determined that

classExec abc.xls

does startup Excel with abc.xls if I first turn off Norton AntiVirus.
The following

classExec abc.xls --action print

does not give me the expected error message about printing (I am still
on the computer with no printer so I am testing that it works by seeing
if I get an error message) but if I change the command to:

classExec abc.xls --command [PRINT]

then I do get the error message so it appears I may have a complete solution
provided I check for .xls file in my batch file and process .xls files
using the above command and other files using commands such as:

classExec abc.doc --action print

with the abc.doc replaced by whatever filename I want to print even if its
a .pdf, .ppt, or .txt file.

I still have to retest all this on a computer with a printer but in
the meantime this is my best potential solution.
 
classExec abc.xls --action print

does not give me the expected error message about printing (I am still
on the computer with no printer so I am testing that it works by seeing
if I get an error message) but if I change the command to:

classExec abc.xls --command [PRINT]

then I do get the error message so it appears I may have a complete solution
provided I check for .xls file in my batch file and process .xls files
using the above command and other files using commands such as:

classExec abc.doc --action print

with the abc.doc replaced by whatever filename I want to print even if its
a .pdf, .ppt, or .txt file.

I still have to retest all this on a computer with a printer but in
the meantime this is my best potential solution.

The success of this usage of classExec depends on the 'Print' DDE shell
handlers in your registry. If there is one for a given file group (i.e.
files with the same extension) classExec should work. You can test this
by right clicking on sample files of all file types you eventually need
to print. If a working(!) 'Print' entry appears in the context menu
classExec should do fine, too.

There are other ways to batch printing jobs. Many programs support
command line parameters for direct printing. PowerPoint for instance
has a /p switch. Winword on the other hand only supports an indirect
way for print-only jobs. You can write a macro which just prints on
the default printer and after that closes Winword. Now you can start
Winword with the /m switch executing your special Print-macro.

Excel is a bit more mulish. But there is a small tool available which
seems to do the trick. KJHDI12 claims in experts-exchange his little
hack PrintXls will do the trick. I have no need to test this. But if
you don't get the needed results with classExec you can look here and
try it on your own:

www.experts-exchange.com/Operating_Systems/WinNT/Q_21089896.html

BeAr
 
The success of this usage of classExec depends on the 'Print' DDE shell
handlers in your registry. If there is one for a given file group (i.e.
files with the same extension) classExec should work. You can test this
by right clicking on sample files of all file types you eventually need
to print. If a working(!) 'Print' entry appears in the context menu
classExec should do fine, too.

Argh! Forgot to mention that the above only is true if the print command
is executed via DDE. You can check this inside the registry. All DDE
print entries have an ddeexec sub-branch beneath the 'Print' subkey.
All /simple/ command line 'Print'-command starters can be called with
their syntax directly from a batch file, though.

BeAr
 
: On 9 Sep 2004 09:03:05 -0700, Grod wrote:
:
: > classExec abc.xls --action print
: >
: > does not give me the expected error message about printing (I am still
: > on the computer with no printer so I am testing that it works by seeing
: > if I get an error message) but if I change the command to:
: >
: > classExec abc.xls --command [PRINT]
: >
: > then I do get the error message so it appears I may have a complete solution
: > provided I check for .xls file in my batch file and process .xls files
: > using the above command and other files using commands such as:
: >
: > classExec abc.doc --action print
: >
: > with the abc.doc replaced by whatever filename I want to print even if its
: > a .pdf, .ppt, or .txt file.
: >
: > I still have to retest all this on a computer with a printer but in
: > the meantime this is my best potential solution.
:
: The success of this usage of classExec depends on the 'Print' DDE shell
: handlers in your registry. If there is one for a given file group (i.e.
: files with the same extension) classExec should work. You can test this
: by right clicking on sample files of all file types you eventually need
: to print. If a working(!) 'Print' entry appears in the context menu
: classExec should do fine, too.
:
: There are other ways to batch printing jobs. Many programs support
: command line parameters for direct printing. PowerPoint for instance
: has a /p switch. Winword on the other hand only supports an indirect
: way for print-only jobs. You can write a macro which just prints on
: the default printer and after that closes Winword. Now you can start
: Winword with the /m switch executing your special Print-macro.
:
: Excel is a bit more mulish. But there is a small tool available which
: seems to do the trick. KJHDI12 claims in experts-exchange his little
: hack PrintXls will do the trick. I have no need to test this. But if
: you don't get the needed results with classExec you can look here and
: try it on your own:
:
: www.experts-exchange.com/Operating_Systems/WinNT/Q_21089896.html

Thanks very much. Since it seems that I will have to special case Excel
anyways its no harder to call printxls and printxls has the advantage that
it seems to work even with Norton Antivirus on. I am still on a computer
with no printer which limits how much I can test but so far this seems to
be the basis for a solution.

By the way, do you know where to get a complete list of possible actions
for use with the action parameter:

classExec file.doc --action X

for Excel, Word, etc. without mucking around in the registry or are the
ones listed when we do this the only ones available:

1. Open windows explorer
2. Select the menu "Tools"
3. Select the menu "Folder options"
4. Choose the tab "file types"
5. Search for the file type DOC
6. Make sure the extension DOC is selected
7. Press the Advanced button

Also how does one get a complete list of the possible commands to use
with the --command parameter (i.e. what goes in the [...])
for Excel, Word, etc.
 
By the way, do you know where to get a complete list of possible actions
for use with the action parameter:

classExec file.doc --action X

As this function of classExec is completely dependent of ddeexec keys
in your registry, you'll only get a complete list by scanning your *own*
registry. I don't remember a specific tool which would do this in a
simple way automatic. If you have orphans of old installations left,
you'll even find more 'actions' in your registry than you truly could
execute.
for Excel, Word, etc. without mucking around in the registry or are the
ones listed when we do this the only ones available:

1. Open windows explorer
2. Select the menu "Tools"
3. Select the menu "Folder options"
4. Choose the tab "file types"
5. Search for the file type DOC
6. Make sure the extension DOC is selected
7. Press the Advanced button

Yes. But in fact it doesn't really matter. If you have a program which
is DDE aware, you can simply create your own DDE shortcuts inside the
registry. That said: The Print-entry you have found for *.doc (for
instance) is nothing more than a Shortcut for a command sequence. You
can see this if you click on 'modify' after your step 7. That leads
directly to your next question:
Also how does one get a complete list of the possible commands to use
with the --command parameter (i.e. what goes in the [...])
for Excel, Word, etc.

You would need a specialized list for any program and version. Generally
spoken: You normally can call all functions which don't return any value.
All other functions should be encapsulated inside macros. So you would
only have to call these macros. Still: I can't provide you an information
source for this topic, which assembles all these functions. Sorry.

BeAr
 
: On 9 Sep 2004 18:27:25 -0700, Grod wrote:
:
: > By the way, do you know where to get a complete list of possible
actions
: > for use with the action parameter:
: >
: > classExec file.doc --action X
:
: As this function of classExec is completely dependent of ddeexec
keys
: in your registry, you'll only get a complete list by scanning your
*own*
: registry. I don't remember a specific tool which would do this in a
: simple way automatic. If you have orphans of old installations left,
: you'll even find more 'actions' in your registry than you truly
could
: execute.
:
: > for Excel, Word, etc. without mucking around in the registry or
are the
: > ones listed when we do this the only ones available:
: >
: > 1. Open windows explorer
: > 2. Select the menu "Tools"
: > 3. Select the menu "Folder options"
: > 4. Choose the tab "file types"
: > 5. Search for the file type DOC
: > 6. Make sure the extension DOC is selected
: > 7. Press the Advanced button
:
: Yes. But in fact it doesn't really matter. If you have a program
which
: is DDE aware, you can simply create your own DDE shortcuts inside
the
: registry. That said: The Print-entry you have found for *.doc (for
: instance) is nothing more than a Shortcut for a command sequence.
You
: can see this if you click on 'modify' after your step 7. That leads
: directly to your next question:
:
: > Also how does one get a complete list of the possible commands to
use
: > with the --command parameter (i.e. what goes in the [...])
: > for Excel, Word, etc.
:
: You would need a specialized list for any program and version.
Generally
: spoken: You normally can call all functions which don't return any
value.
: All other functions should be encapsulated inside macros. So you
would
: only have to call these macros. Still: I can't provide you an
information
: source for this topic, which assembles all these functions. Sorry.
:


For .doc files, I tried to create a batch file, a.bat, based on the
DDE string that is found under Edit (modify on your system) for .DOC
files action print. This gives me the following one line batch file
(it may get wrapped to two lines in posting but it should be one
line):

-------- a.bat ---------------
classExec %1 --command "[REM
_DDE_Minimize][FileOpen(\"%1\")][t=IsDocumentDirty()][FilePrint
0][SetDocumentDirty t][DocClose]"
------------------------------

but it just hangs when I run

a.bat test.doc

where test.doc is a simple Word file I created. I am using XP and
Word 2002. Are you able to verify that DDE strings found under
Edit or Modify actually work with classExec?
 
For .doc files, I tried to create a batch file, a.bat, based on the
DDE string that is found under Edit (modify on your system) for .DOC
files action print. This gives me the following one line batch file
(it may get wrapped to two lines in posting but it should be one
line):

-------- a.bat ---------------
classExec %1 --command "[REM
_DDE_Minimize][FileOpen(\"%1\")][t=IsDocumentDirty()][FilePrint
0][SetDocumentDirty t][DocClose]"
------------------------------

but it just hangs when I run

a.bat test.doc

where test.doc is a simple Word file I created. I am using XP and
Word 2002. Are you able to verify that DDE strings found under
Edit or Modify actually work with classExec?

No problems here. Tested with Winword 97 on W2k. This is the syntax
of *my* DDE print command (out of the registry):

classExec %1 --command "[FileOpen(\"%1\")][FilePrint 0][FileExit 2]"

Your command works, too. (Which was not necessary expected, as the
macro syntax between Word 97 and Word 2002 is not completely identic.)
You can test the command by opening test.doc and creating a new macro
which contains a single line for each command listed above in square
brackets. (The call of classExec simply does the same, temporarily!)

The first line can be omitted. It is disabled by the REM command.
(Don't know why it is included at all?!!) The last command (DocClose)
is not very wise chosen, either. It only closes the active Document,
but still keeps Winword open. Replace it by FileExit.

Hope, you find and solve your problem!
BeAr
 
B. R. 'BeAr' Ederson said:
For .doc files, I tried to create a batch file, a.bat, based on the
DDE string that is found under Edit (modify on your system) for .DOC
files action print. This gives me the following one line batch file
(it may get wrapped to two lines in posting but it should be one
line):

-------- a.bat ---------------
classExec %1 --command "[REM
_DDE_Minimize][FileOpen(\"%1\")][t=IsDocumentDirty()][FilePrint
0][SetDocumentDirty t][DocClose]"
------------------------------

but it just hangs when I run

a.bat test.doc

where test.doc is a simple Word file I created. I am using XP and
Word 2002. Are you able to verify that DDE strings found under
Edit or Modify actually work with classExec?

No problems here. Tested with Winword 97 on W2k. This is the syntax
of *my* DDE print command (out of the registry):

classExec %1 --command "[FileOpen(\"%1\")][FilePrint 0][FileExit 2]"

Your command works, too.


Your successful attempt motivated me to try classExec again
with the DDE string found in Windows Explorer. After
repeated failures I discovered that simply rebooting got it
working. I have no idea how it got into some state where it
failed to work prior to the reboot.

In the case of Word, say, I am still trying to figure out
what the commands are that go in the [...]. Are these
Visual Basic? Visual Basic for Applications? WordBasic?
vbscript? something else?
 
Your successful attempt motivated me to try classExec again
with the DDE string found in Windows Explorer. After
repeated failures I discovered that simply rebooting got it
working. I have no idea how it got into some state where it
failed to work prior to the reboot.

Congrats! ;-)
In the case of Word, say, I am still trying to figure out
what the commands are that go in the [...]. Are these
Visual Basic? Visual Basic for Applications? WordBasic?
vbscript? something else?

In general: WordBasic in older versions of Winword and Word-VBA for
newer should be fine, as long as you don't require a return value of
the whole 'macro'. - You *really* should think of these DDE strings as
of a macro. Like I said in my previous post: classExec with --command
option (and strictly spoken all Explorer driven DDE commands, too)
simply copies all listed commands of the DDE string (every single
command you see encapsulated in square brackets) line by line in a
temporary macro. (The square brackets are of course omitted!)

For tests you should just write the functionality you wish to achieve
in a macro. There you can test back and force until all works well.
After that you can simply decide to call your macro with the command
option of classExec by name or copy all single function calls into
the command option. (Enclosing each line of your macro in those square
brackets and copying all onto one line, of course.)

You have to bear one thing in mind: If a DDE call does not succeed it
can lead to an entry of your temporary macro into normal.dot which
doesn't get deleted. In such cases you have to delete this macro
manually to get DDE working again.

One more thought regarding the possible use of additional functions.
If you use the 'Declare function' statement inside your DDE commands
you should be able to use nearly unlimited external functionality.
Whether this is *really* an option and if this is a wise thing to
do at all - I don't know... ;-)

BeAr
 
Back
Top