Bonjour à tous,
voici le code modifié avec l'ajout d'une boucle pour imprimer tous les bulletins. Il faut d'abord changer dans la feuille BULLETIN cellule H5 la référence pour exclure l'en-tête MATRICULE.
='élements de salaires'!$A$2:$A$102 devient ='élements de salaires'!$A$3:$A$102
Sub Export_BulletinSalaire() 'sans impression*****************ok au 12/02/2022
Dim Fichier As String
Dim plage As Range
Dim first As Variant
Dim r As Range, c As Range, inputRange As Range
'Set plage = Intersect([1:65536], ActiveSheet.UsedRange)
Set plage = Sheets("BULLETIN").Range("A1:J62")
If Not plage Is Nothing Then ActiveSheet.PageSetup.PrintArea = plage.Address
' Location of DataValidation cell
Set r = Worksheets("BULLETIN").Range("H5")
' Get DataValidation values
Set inputRange = Evaluate(r.Validation.Formula1)
Application.ScreenUpdating = False
For Each c In inputRange
If first = "" Then first = c.Value
If c <> "" Then
r.Value = c.Value
DateH = Format(Date, "dd_mm_yyyy")
'adaptez le nom de la feuille
With Worksheets("BULLETIN")
Fichier = .Range("H6") & " Du " & DateH & ".pdf"
dossier = ThisWorkbook.Sheets("PARAMETRES").Range("M4").Value 'chemin à modifier dans PARAMETRES
Chemin = dossier & Fichier
.ExportAsFixedFormat Type:=xlTypePDF, Filename:=Chemin, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
End With
End If
Next c
' réinitialiser
r = first
Application.ScreenUpdating = True
End Sub