Trapping print (&close) requests

S

Scott Ribe

This is a scripting question: how can I trap print requests and act on them?
I've worked with FileSave and I'm wanting the same functionality for
printing.

Also, closing. I note that when a user closes a modified document and
confirms to save it, FileSave is not called.
 
P

Paul Berkowitz

This is a scripting question: how can I trap print requests and act on them?
I've worked with FileSave and I'm wanting the same functionality for
printing.

If you mean "by AppleScript" when you say "scripting", then you can't. There
are no "events" via AppleScript: you cannot trap user clicks or menu
selections. If you mean via VBA, then perhaps it is possible, since Events
do exist in VBA, though I don't know how they work. I am not sure if
printing, or File/Print, can be trapped, but somebody else here will know.
However, even if it is possible, it would no longer work in the next version
of Word (2008) to be released later this year, where VBA will no longer
exist.
Also, closing. I note that when a user closes a modified document and
confirms to save it, FileSave is not called.

That would be FileClose: you could trap for that and call your own dialog as
to whether to save or not, then act accordingly if the answer is Yes.


--
Paul Berkowitz
MVP MacOffice
Entourage FAQ Page: <http://www.entourage.mvps.org/faq/index.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 Microsoft Office you are using -
**2004**, X or 2001. It's often impossible to answer your questions
otherwise.
 
D

Daiya Mitchell

Paul said:
If you mean via VBA, then perhaps it is possible, since Events
do exist in VBA, though I don't know how they work. I am not sure if
printing, or File/Print, can be trapped, but somebody else here will know.

I believe so. FilePrint calls the Print dialog box, FilePrintDefault
sends the document immediately to the printer. You'll need to intercept
them both, I assume.
 
J

JE McGimpsey

Scott Ribe said:
This is a scripting question: how can I trap print requests and act on them?
I've worked with FileSave and I'm wanting the same functionality for
printing.

There isn't a Print Event, but you can trap the commands.

Put this in a regular code module in a global template:

Public Sub FilePrint()
MyPrint
End Sub

Public Sub FilePrintDefault()
MyPrint
End Sub

Public Sub MyPrint()
'do whatever...
MsgBox "Intercepted printing"
ActiveDocument.PrintOut
End Sub
 

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