Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / February 2005

Tip: Looking for answers? Try searching our database.

HOWTO Make a Word Doc Template do tasks when user goes to print.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ATS - 10 Feb 2005 21:51 GMT
HOWTO Make a Word Doc Template do tasks when user goes to print.

Please help, I'm kind of new to VB for Word

I want to make a Word for Windows document template that traps the "onprint"
event to do "things" in the back ground, just after the print has completely
succeeded.

First of all, I can not even slightly find a "onprint" event like "thingy"
in the Word's Macro/VB editor for Word 2000. It should be something like

Sub Document_OnPrint
 MsgBox "Hello!!!!"
End Sub

The next thing is how to know that printing succeeded. That is, how to know
that as far as "Word" is concerned, the print job succeeded. It should be
something like this:

Sub Document_OnPrint
 Results = Document.~~~Finish~~The~~Print~~Job()

 If Result = ~~SUCCESS~~ Then
   ~~~~ Do My Stuff... ~~~~
 End If
End Sub

Lastly, I want (if possible) to "trap" all of the output parameters that
were used for the print job so that I can "duplicate" them into a "background
print job", kind of like this:

Sub Document_OnPrint
 PrintJobSettings = Document.Get~~Print~~Job~~Settings
 Results = Document.~~~Finish~~The~~Print~~Job()

 If Result <> ~~SUCCESS~~ Then
   Exit Sub
 End
 
 Document.Create~~New~~Print~~Job ~~Pass~~In~~ PrintJobSettings
 Results = Document.~~~Finish~~The~~Print~~Job()

 If Result <> ~~SUCCESS~~ Then
   MsgBox "Oh oh!!!!"
 End
End Sub
Doug Robbins - 10 Feb 2005 23:55 GMT
If you create a macro with the name of one of Word's built in commands, that
macro will run in place of the command when the use attempts to use the
command  You can see the names of the commands in the Macros dialog by
selecting the Word Commands item in the Macros in pulldown.  In this case,
the ones that you will need are FilePrint and FilePrintDefault.  If you set
the Background Print attribute of the .Print command to false, the code that
you want to run after the printing has finished will not run until that
time.

Signature

Please respond to the Newsgroup for the benefit of others who may be
interested.   Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP

> HOWTO Make a Word Doc Template do tasks when user goes to print.
>
[quoted text clipped - 46 lines]
>  End
> End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.