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