Print Multiple Documents

S

Sam L Elowitch

Is it possible to print more than one Word (v. X) document with a single
command (e.g., Print All or Print All Open Documents or Print All Documents
in Folder...)?

-Sam
 
S

Sam L Elowitch

(Apologies for replying to my own post)

Well, I was able to create and use this AppleScript successfully:

tell application "Microsoft Word"
print all documents
end tell

This works, but it also reminded me how disappointed I am that this function
isn't built into Word and that Word (unlke Entourage) lacks a dedicated
Scripts menu.

-Sam
 
S

Sam L Elowitch

(Again, sorry for the reply to my own post)

Interestingly, if I amend the script to:

tell application "Microsoft Word"
print all documents without dialog
end tell

I still get a print dialog for each document. Nuts.

-Sam
 
D

Dayo Mitchell

Hi Sam,

Please don't apologize, it's very helpful to see you working this out,
especially for me who is only just learning basic applescript.

Just to confirm, this script:prints all open documents immediately?
With or without the dialog box?

Re a Scripts menu in Word, be sure to Send Feedback (under Help) and ask for
it for future versions!

Dayo
 
S

steve

Dayo Mitchell said:
Hi Sam,

Please don't apologize, it's very helpful to see you working this out,
especially for me who is only just learning basic applescript.

Just to confirm, this script:prints all open documents immediately?
With or without the dialog box?

Re a Scripts menu in Word, be sure to Send Feedback (under Help) and ask for
it for future versions!

Dayo


Sam L Elowitch said:
(Again, sorry for the reply to my own post)

Interestingly, if I amend the script to:

tell application "Microsoft Word"
print all documents without dialog
end tell

I still get a print dialog for each document. Nuts.

-Sam
Is it possible that the print dialog is coming from your printer
driver and not Word: therefore the script is doing its thing but only
within Word?
 
S

Sam L Elowitch

Hello, Dayo.

To clarify:

1. This example prints all open documents (but WITH the dialog boxes for
each, unfortunately):
tell application "Microsoft Word"
print all documents
end tell

2. The following is supposed to print only the active document while
skipping the dialog:
tell application "Microsoft Word"
do Visual Basic "ActiveDocument.PrintOut"
end tell

What would be great as a next step is to make #2 loop through all of the
open documents and print them all the same way, sans dialog.

Happy Easter/Passover/Other Holiday to all.

-Sam

Hi Sam,

Please don't apologize, it's very helpful to see you working this out,
especially for me who is only just learning basic applescript.

Just to confirm, this script:prints all open documents immediately?
With or without the dialog box?

Re a Scripts menu in Word, be sure to Send Feedback (under Help) and ask for
it for future versions!

Dayo
 
J

John McGhie [MVP - Word]

Hi Sam:

In VBA, that would be:

For Each openDoc In Documents
openDoc.PrintOut
Next openDoc

While the following example prints all of the documents in the folder:

adoc = Dir("*.DOC")
While adoc <> ""
Application.PrintOut FileName:=adoc
adoc = Dir()
Wend

But what I would normally do is create a desktop printer as described in the
Apple OS X Help item " Creating a desktop icon for a printer" then simply
select all the documents I wanted to print and drag them to the desktop
icon.

Check in Word>Preferences that you have Background Printing enabled. If you
haven't, Word will produce a dialog for each.

Hope this helps

from "Sam L said:
Hello, Dayo.

To clarify:

1. This example prints all open documents (but WITH the dialog boxes for
each, unfortunately):
tell application "Microsoft Word"
print all documents
end tell

2. The following is supposed to print only the active document while
skipping the dialog:
tell application "Microsoft Word"
do Visual Basic "ActiveDocument.PrintOut"
end tell

What would be great as a next step is to make #2 loop through all of the
open documents and print them all the same way, sans dialog.

Happy Easter/Passover/Other Holiday to all.

-Sam

Hi Sam,

Please don't apologize, it's very helpful to see you working this out,
especially for me who is only just learning basic applescript.

Just to confirm, this script:
Prints all open documents immediately?
With or without the dialog box?

Re a Scripts menu in Word, be sure to Send Feedback (under Help) and ask for
it for future versions!

Dayo

--

Please respond only to the newsgroup to preserve the thread.

John McGhie, Consultant Technical Writer,
McGhie Information Engineering Pty Ltd
Sydney, Australia. GMT + 10 Hrs
+61 4 1209 1410, mailto:[email protected]
 
P

Paul Berkowitz

The equivalent in AppleScript (and adding a 'Dim' line just in case the VB
Editor is set to 'Option Explicit') would be

tell application "Microsoft Word"
do Visual Basic "
Dim openDoc As Document
For Each openDoc In Documents
openDoc.PrintOut
Next openDoc
"
end tell


_Please_ do ask MS to provide a Script menu. However, you can make use of
the system script menu if you are in OS 10.2 or 10.3. It's just as
convenient. For complex scripts it's slower than a native Word script menu
would be, but in 10.3 Apple has improved so you'd hardly notice.

In Panther (OS 10.3):

1. Go to /Applications/AppleScript/Install Script Menu and double-click it.

2. You'll now see a black Script menu over on the right side of your main
menu bar.

3. Select it, and in the dropdown select "Open Scripts Folder". That creates
and opens a folder here: ~/Library/Scripts/, which is the right placer for
personal scripts. (You won't see the other scripts i the menu there: they're
all in either /System/Library/Scripts/ and /Library/Scripts/.)

4. You have a choice. You can either:
a) Put your compiled script in that ~/Library/Scripts/ folder. It's now
available everywhere, but you don't really need that, and you can clutter up
the scripts menu with too many.
b) Make a Word or Microsoft Word subfolder and put it there. Same as a)
only it's less cluttered but requires another click with a sub-menu item.
c) Make an "Applicatios" subfolder, then a "Microsoft Word" (exactly)
subfolder within that and put your script there. Now it will show up _only_
when you're in Word in the front, and will appear at the bottom of te
Scripts menu with no submenu items needed. It's by far the best solution.
You can do the same for other applications too.


In Jaguar (OS 10.2):

1. Go to /Applications/AppleScript/Script Menu.menu and double-click it.

2. You'll now see a black Script menu over on the right side of your main
menu bar.

3 and 4 as above, but 4c is not available in Jaguar.


You can now run the scripts from the black Scripts menu when you're in Word.
However, you cannot assign a keyboard shortcut to scripts in the system
Scripts menu, unlike application script men us such as Entourage's, Tex-Edit
Plus, BBEdit, etc.

The alternative is to do the native Word thing. You'd create a pair of VBA
macros:

'''''''''''''''''''''''''''''''

Sub AddDateButtonToToolbar()

Dim newItem As CommandBarButton

Set newItem =
CommandBars("Standard").Controls.Add(Type:=msoControlButton)
With newItem
.BeginGroup = True
.Caption = "Print All"
.FaceId = 4
.OnAction = "PrintOpenDocs"
End With
End Sub


Sub PrintOpenDocs()
Dim openDoc As Document
For Each openDoc In Documents
openDoc.PrintOut
Next openDoc
End Sub

''''''''''''''''''''''''''''''''''''

in a new Template. (File/New Blank Document. In Tools/Macros/Visual Basic
Editor/Insert Module, paste the macros above. Then File/Save, and in the
Save As window, give it a name such as "Print Open Docs", **change the
format to "Document Template", and save it to /Applications/Microsoft Office
X/Office/Startup/Word. Check to include extension, which will be .dot.)
Alternatevely you can save it in Normal template, which is in the Templates
subfolder of Microsoft Office X, but I prefer to put macros like this into
separate startup templates - Normal can get messy if corrupt.

Either way, each time you open Word you'll find a new Print All button in
your standard toolbar. You can also assign it a Keyboard shortcut via
Tools/Customize Keyboard/. Select Macros in the left column, PrintOpenDocs
in right column, click in the "Press new shortcut key" box and press, e.g.
Command + Control + P. (If you press a combo that has aleready been assigned
to something else, you'll be informed. Delete and try again.)

So now you'll have both a button and a keyboard shortcut to do this. It's
certainly more complicated than AppleScript, especially if you had to figure
out how to add a new button in VBA by yourself. (I chose the old Print icon
for you with .FaceId = 4. It's another business to get the pages and pages
on icons available.) You may just find that the sustem Script menu does the
job just as well, and much more easily.

--
Paul Berkowitz
Mac MVP (Entourage)
AppleScripts for Entourage: <http://macscripter.net/scriptbuilders/>

Please "Reply To Newsgroup" to reply to this message. Emails will be
ignored.

PLEASE always state which version of Entourage you are using - 2001 or X.
It's often impossible to answer your questions otherwise.

From: "John McGhie [MVP - Word]" <[email protected]>
Newsgroups: microsoft.public.mac.office.word
Date: Sat, 10 Apr 2004 23:26:33 +1000
Subject: Re: Print Multiple Documents

Hi Sam:

In VBA, that would be:

For Each openDoc In Documents
openDoc.PrintOut
Next openDoc

While the following example prints all of the documents in the folder:

adoc = Dir("*.DOC")
While adoc <> ""
Application.PrintOut FileName:=adoc
adoc = Dir()
Wend

But what I would normally do is create a desktop printer as described in the
Apple OS X Help item " Creating a desktop icon for a printer" then simply
select all the documents I wanted to print and drag them to the desktop
icon.

Check in Word>Preferences that you have Background Printing enabled. If you
haven't, Word will produce a dialog for each.

Hope this helps

from "Sam L said:
Hello, Dayo.

To clarify:

1. This example prints all open documents (but WITH the dialog boxes for
each, unfortunately):


2. The following is supposed to print only the active document while
skipping the dialog:


What would be great as a next step is to make #2 loop through all of the
open documents and print them all the same way, sans dialog.

Happy Easter/Passover/Other Holiday to all.

-Sam

--

Please respond only to the newsgroup to preserve the thread.

John McGhie, Consultant Technical Writer,
McGhie Information Engineering Pty Ltd
Sydney, Australia. GMT + 10 Hrs
+61 4 1209 1410, mailto:[email protected]
 
P

Paul Berkowitz

4. You have a choice. You can either:
a) Put your compiled script in that ~/Library/Scripts/ folder. It's now
available everywhere, but you don't really need that, and you can clutter up
the scripts menu with too many.
b) Make a Word or Microsoft Word subfolder and put it there. Same as a)
only it's less cluttered but requires another click with a sub-menu item.
c) Make an "Applicatios" subfolder, then a "Microsoft Word" (exactly)
subfolder within that and put your script there. Now it will show up _only_
when you're in Word in the front, and will appear at the bottom of te Scripts
menu with no submenu items needed. It's by far the best solution. You can do
the same for other applications too.

Several misspellings there - one fatal. Sorry - I happen to be using a test
build where the spell-checker isn't working. That should be an
"Applications" subfolder, of course. So this paragraph should read (with a
couple of grammar corrections too ;-):

4. You have a choice. You can either:
a) Put your compiled script in that ~/Library/Scripts/ folder. It's now
available everywhere, but you don't really need that, and you can clutter up
the scripts menu with too many. scripts
b) Make a Word or Microsoft Word subfolder and put the script there. Same
as a) only it's less cluttered but requires another click for a sub-menu item.
c) Make an "Applications" subfolder, then a "Microsoft Word" (exactly)
subfolder within that and put your script there. Now it will show up _only_
when you're in Word in the front, and will appear at the bottom of the Scripts
menu with no submenu items needed. It's by far the best solution. You can do
the same for other applications too.


--
Paul Berkowitz
MVP Entourage
Entourage FAQ Page: <http://www.entourage.mvps.org/toc.html>
AppleScripts for Entourage: <http://macscripter.net/scriptbuilders/>

Please "Reply To Newsgroup" to reply to this message. Emails will be
ignored.

PLEASE always state which version of Entourage you are using - 2001 or X.
It's often impossible to answer your questions otherwise.
 

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