Sub PDF()
If Not ActiveSheet.Name Like "bulletin*" Then Exit Sub 'sécurité
Dim chemin$, rep As Byte, a$, h&, i&
chemin = ThisWorkbook.Path & "\Sauvegarde\"
If Dir(chemin, vbDirectory) = "" Then MkDir chemin 'création du dossier
rep = MsgBox("Grouper en un seul fichier PDF ?'", 3)
If rep = 2 Then Exit Sub
Application.ScreenUpdating = False
With ActiveSheet
.PageSetup.Zoom = False
.PageSetup.FitToPagesTall = 1 '1 page en hauteur, détermine le zoom
If rep = 6 Then 'Oui
a = .PageSetup.PrintArea
h = .Range(a).Rows.Count
.Copy 'nouveau document
With ActiveSheet
.PageSetup.PrintArea = ""
For i = 1 To Val(.[N7] - 1)
.Range(a).EntireRow.Offset(h * i - h).Copy .[A1].Offset(h * i)
.[N5].Offset(h * i) = i + 1
.HPageBreaks.Add Before:=.[A1].Offset(h * i) 'saut de page
Next
.PageSetup.PrintArea = .Range(a).Resize(h * i).Address
.PageSetup.FitToPagesTall = i
.ExportAsFixedFormat xlTypePDF, chemin & "Groupé.pdf"
.Parent.Close False 'fermeture du document
End With
MsgBox "Fichier PDF groupé publié..."
Else 'Non
For i = 1 To Val(.[N7])
.[N5] = i
.ExportAsFixedFormat xlTypePDF, chemin & .[N5] & ".pdf"
Next
.[N5] = 1
MsgBox i - 1 & " fichier(s) PDF publié(s)..."
End If
End With
End Sub