Sub Tst5()
Dim sNomFichierPS As String
Dim sNomFichierPDF As String
Dim sNomFichierLog As String
Dim PDFDist As PdfDistiller, PrinterDefault As String
PrinterDefault = Application.ActivePrinter
If Imprimante_AdobePDF Then
Application.ActivePrinter = sNomPortReseau
Else
MsgBox "Pas d'imprimante Adobe PDF sur NeXY ", vbOKOnly + vbCritical, "Achtung"
Exit Sub
End If
sNomFichierPS = ThisWorkbook.Path & "\Trimestre 4.ps"
sNomFichierPDF = ThisWorkbook.Path & "\Trimestre 4.pdf"
sNomFichierLog = ThisWorkbook.Path & "\Trimestre 4.log"
Application.ScreenUpdating = False
Sheets(Array("Trimestre 4")).PrintOut copies:=1, Preview:=False, _
ActivePrinter:=sNomPortReseau, PrintToFile:=True, _
PrToFileName:=sNomFichierPS
Set PDFDist = New PdfDistiller
PDFDist.FileToPDF sNomFichierPS, sNomFichierPDF, ""
Set PDFDist = Nothing
Kill sNomFichierPS
Kill sNomFichierLog
Application.ScreenUpdating = True
Application.ActivePrinter = PrinterDefault
UserForm8.Show
End Sub
Private Function Imprimante_AdobePDF() As Boolean
Dim i As Integer
' 11 imprimantes réseau
Imprimante_AdobePDF = False
For i = 0 To 10
If i < 10 Then
sNomPortReseau = "Adobe PDF sur Ne0" & i & ":"
Else
sNomPortReseau = "Adobe PDF sur Ne" & i & ":"
End If
On Error Resume Next
Application.ActivePrinter = sNomPortReseau
If ActivePrinter = sNomPortReseau Then
Imprimante_AdobePDF = True
Exit For
End If
Next i
End Function