Command line printing

I

Ihab Badr

Folks,

I am using Office 2001 on OS X.2
Is there a way to print a WORD document from the command line?
Using lpr does not work as I suspect lpr does not understand the WORD format.

Thanks in Advance
 
C

Corentin Cras-Méneur

Ihab Badr said:
Folks,

I am using Office 2001 on OS X.2
Is there a way to print a WORD document from the command line?
Using lpr does not work as I suspect lpr does not understand the WORD format.

I'm not sure at all you can do it... You could probably convert the
files to PDF first and then print these through the command line, but
I'm not sure that's the solution you are looking for :-(

Corenin
 
J

John McGhie

The lpr function simply pumps strings out of the defined port. You need to
ensure the strings are what your printer understands.

To do this, you need to call Word's print routine to hand the document off
to the OS X PDF converter.

Use AppleScript to create a running instance of Word, then use the GetObject
function to return it to your script, and the application.printout function
to print the list of documents you provide.

I'm not an AppleScript person, but there are plenty here who can tell you
how to do that.

You do need to create an instance of Word, but you can create a hidden
instance that the user is not aware of and you have total control over.

I am told that the AppleScript support in Word 2001 sux, and that calling an
application within a guest operating system is rather an extreme measure.
Had you thought of purchasing a copy of Word 2004? AppleScript support is
vastly improved in 2004.

Cheers


Folks,

I am using Office 2001 on OS X.2
Is there a way to print a WORD document from the command line?
Using lpr does not work as I suspect lpr does not understand the WORD format.

Thanks in Advance

--

Please reply to the newsgroup to maintain the thread. Please do not email
me unless I ask you to.

John McGhie <[email protected]>
Consultant Technical Writer
Sydney, Australia +61 4 1209 1410
 
R

Rob Daly [MSFT]

If you're looking for a simple way to print from the desktop in Word X
through an applescript, the following script would work (this is just code
for the printing). By the way - command line is not an option.

tell application "Microsoft Word"
activate

set theDoc to <enter mac path to the file here> --something like "Mac OS
X: users: me: documents: mydoc"

do Visual Basic "application.displayalerts - wdAlertsNone"
do Visual Basic "activedocument.printout"
do Visual Basic "application.displayalerts - wdAlertsAll"

quit saving no

end tell

Here is some explanation of why I wrote it this way:

I use visual basic commands because the Office suite "print" command in
version X Applescript with bring up the Print Dialog - I'm guessing you do
not want that. Also - I'm guessing that you are trying to get a fast
printout without any app interaction. That is why I quit word at the end. It
also explains why I used the visual basic "displayalerts" method. In the two
lines that use it, I am telling word to (1) accept all alert defaults and
(2) show all alerts again - this is because I need to set it back to show
all alerts afterwards as it won't get set back otherwise. Why do I do this?
so that margin warnings won't stop the script.

In order to really get this script to approach something that runs from the
desktop, you would need to make it into a droplet script where you drag the
file you want to print onto the script and that then becomes the variable
"theDoc". I won't go into how to do that in Applescript here as I'm sure
others are eeking to tell you ;)


--
Rob Daly
Macintosh Business Unit
Word Test

--
This posting is provided "AS IS" with no warranties, and confers no rights.
Please do not send email directly to this e-mail address. It is for
newsgroup purposes only.

Find out everything about Microsoft Mac Newsgroups at:
http://www.microsoft.com/mac/community/community.aspx?pid=newsgroups
Check out product updates and news & info at:
http://www.microsoft.com/mac
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top