Re: Command line printing
From: Rob Daly [MSFT] (rdaly_at_online.microsoft.com)
Date: 12/10/04
- Next message: Beth Rosengard: "Re: Can't paste in Office applications"
- Previous message: Jeffrey Weston [MSFT]: "Re: Word 2004 gets stuck when I try to display the drawing toolbar"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 10 Dec 2004 10:14:34 -0800
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 "John McGhie" <john@mcghie.name> wrote in message news:BDC40A69.C978%john@mcghie.name... > 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 > > > On 18/11/04 10:42 PM, in article > 6f147b4b.0411180342.31183798@posting.google.com, "Ihab Badr" > <ihabbadr@netscape.net> wrote: > >> 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 <john@mcghie.name> > Consultant Technical Writer > Sydney, Australia +61 4 1209 1410 >
- Next message: Beth Rosengard: "Re: Can't paste in Office applications"
- Previous message: Jeffrey Weston [MSFT]: "Re: Word 2004 gets stuck when I try to display the drawing toolbar"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|