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
| Option Explicit
Declare Function apiShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _
ByVal hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) _
As Long
Public Sub PrintPDF()
Dim kRow As Long, sDoss As String, sPdf As String
sDoss = "D:\Système Hydro\RESET\Sauvegarde Générale (pendant cette année)\Rapport- Devis\Fiche ID\Fiche ID NomCommune 2019\NomFichier.pdf"
With Sheets("FD")
For kRow = 28 To 37
If .Range("D" & kRow) <> "" Then
sPdf = Replace(sDoss, "NomCommune", .Range("E5"))
sPdf = Replace(sPdf, "NomFichier", .Range("D" & kRow))
If Dir(sPdf) = "" Then
MsgBox "Fichier manquant:" & vbCrLf & sPdf, , "Anomalie"
Else
Call apiShellExecute(Application.hwnd, "print", sPdf, vbNullString, vbNullString, 0)
End If
End If
Next kRow
End With
End Sub |
Partager