red6000 was telling us:
red6000 nous racontait que :
You could use something like the following to intercept the user attempts at
printing.
The two subs must be named as they are so that they will kick in whenever a
user
does CTRL-P, File > Print or clicks on the print button on the toolbar.
'_______________________________________
Function boolFunCheckPrinter() As Boolean
Dim strPrinter As String
Const strTarget As String = "Target Printer Name"
strPrinter = Trim$(Left$(ActivePrinter, _
InStr(ActivePrinter, " on ")))
If strPrinter = strTarget Then
MsgBox "You cannot use the """ & strTarget & """ printer.", vbCritical,
"Denied"
boolFunCheckPrinter = False
Else
boolFunCheckPrinter = True
End If
End Function
'_______________________________________
'_______________________________________
Sub FilePrint()
Dim strRange As String
Dim strCopy As String
Dim strPages As String
Dim dlgPrint As Dialog
Set dlgPrint = Dialogs(wdDialogFilePrint)
'-1 = OK button
With dlgPrint
If .Display = -1 Then
'Store user choices from dialog box
strRange = .Range
strPages = .Pages
strCopy = .NumCopies
If boolFunCheckPrinter Then
'Print document using user choices
With Dialogs(wdDialogFilePrint)
.Range = strRange
.Pages = strPages
.NumCopies = strCopy
.Execute
End With
End If
End If
End With
End Sub
'_______________________________________
'_______________________________________
Sub FilePrintDefault()
If boolFunCheckPrinter Then ActiveDocument.PrintOut
End Sub
'_______________________________________
You may want to store more options from the dialog box. Here is the list of
arguments that MSFT claims that can be used.... This is notoriously
under-documented an unreliable...:
Background, AppendPrFile, Range, PrToFileName, From, To, Type, NumCopies,
Pages, Order, PrintToFile, Collate, FileName, Printer, OutputPrinter,
DuplexPrint, PrintZoomColumn, PrintZoomRow, PrintZoomPaperWidth,
PrintZoomPaperHeight, ZoomPaper
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site:
http://www.word.mvps.org