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
| Sub createPdf()
Dim Dossier As String
Dim CheminFichier As String
Dim ws As Worksheet
Dim ligne As Long
Dim lastRow As Long
Dim lastColumn As Long
Dossier = "situation"
CheminFichier = ThisWorkbook.Path & "/" & Dossier & "/"
Set ws = Sheets("filtre")
Application.ScreenUpdating = False
ActiveWorkbook.RefreshAll
On Error Resume Next
If CheminFichier = True Then
GetAttr (CheminFichier) And vbDirectory
Else
MkDir CheminFichier
End If
lastRow = Sheets("TCD").Range("A" & Rows.Count).End(xlUp).Row
For ligne = 4 To lastRow
lastColumn = Sheets("TCD").Rows(ligne).Find("*", searchorder:=xlByColumns, searchdirection:=xlPrevious).Column
If lastColumn > 1 Then ' Vérifie si la ligne contient des données
ws.Range("D4").Value = Sheets("TCD").Cells(ligne, 1)
ws.ExportAsFixedFormat xlTypePDF, CheminFichier & ws.Range("D4").Value & ".pdf", _
xlQualityStandard, True, False, 1, , False
End If
Next ligne
Application.ScreenUpdating = True
End Sub |
Partager