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 / March 2007

Tip: Looking for answers? Try searching our database.

DocumentBeforePrint event

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Helen Trim - 29 Mar 2007 11:18 GMT
Is there a way to see how many copies were requested in the
DocumentBeforePrint event?  I store documents in a database and I need to
store how many copies are needed and how many have already been printed.

Thanks,
Helen
old man - 31 Mar 2007 03:32 GMT
Hi,

This will work (based on code from a recent answer from Jay Friedman in this
forum):

dim intSaveNumCopies as integer ' will contain numbr of copies printed

Dim dlgPrint As Dialog
   Set dlgPrint = Dialogs(wdDialogFilePrint)
   With dlgPrint
       .Display
      ' you can check if the user wants to print... lets assume they do

       ActiveDocument.PrintOut _
       Background:=True, _
       Range:=.Range, _
       from:=.from, to:=.to, _
       Item:=wdPrintDocumentWithMarkup, _
       Copies:=.numcopies, _
       Pages:=.Pages
       intSaveNumCopies = dlgPrint.numcopies
   End With

To understand how to set word  applications event please read:
http://word.mvps.org/faqs/macrosvba/AppClassEvents.htm
and
http://msdn2.microsoft.com/en-us/library/aa140279(office.10).aspx

I created a routine in the template:
Private Sub AppThatLooksInsideThisEventHandler_DocumentBeforePrint(ByVal Doc
As Document, Cancel As Boolean)
MsgBox "in app event before print app event"
End Sub

I created a subroutine with the following code in the word document:
Sub fileprint()
MsgBox "fp"
Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
       wdPrintDocumentContent, Copies:=2, Pages:="",
PageType:=wdPrintAllPages, _
       ManualDuplexPrint:=False, Collate:=True, Background:=True,
PrintToFile:= _
       False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _
       PrintZoomPaperHeight:=0
End Sub

When I opened the document and attached the template with app event this is
the order of what I saw:

1) A msgbox that said "FP"
2) a msgbox that said "in app event before print app event" 'app event
3) The document printed

So intercepting the event won't help because it occurs  before the print
(application.printout)

old man

> Is there a way to see how many copies were requested in the
> DocumentBeforePrint event?  I store documents in a database and I need to
> store how many copies are needed and how many have already been printed.
>
> Thanks,
> Helen
 
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.