1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
Sub VaziImprimeLe(lekel As String, tonimprimante As String, Optional leouerre As String)
' Force l'impression sur une imprimante connue 1 ex.
' tonimprimante nom de l'imprimante
' lekel nom de l'état
' leouerre Clause Where de l'état
Dim NumIMP As Integer
Dim NombreImp As Integer
Dim ImpCherche
Dim cpt As Integer
NumIMP = 0
NombreImp = Application.Printers.Count
For Each ImpCherche In Application.Printers
If ImpCherche.DeviceName = tonimprimante Then
Set Application.Printer = Application.Printers(NumIMP)
Exit For
Else
NumIMP = NumIMP + 1
End If
Next ImpCherche
If NumIMP = NombreImp Then
MsgBox "Gasp, vous n'avez pas d'imprimante " + tonimprimante, vbCritical, "Impossible !"
Exit Sub
End If
If leouerre <> "" Then
DoCmd.OpenReport lekel, acViewPreview, , leouerre ' ICI Etat avec Clause Where
Else
DoCmd.OpenReport lekel, acViewPreview
End If
DoCmd.PrintOut acPrintAll, , , 1
DoCmd.Close acReport, lekel
Set Application.Printer = Nothing
End Sub |
Partager