Private Sub UserForm_Initialize()
Dim F As Worksheet, nf$, a$(), n&, dat As Variant, ouvre As Boolean
Me.Height = Application.Height
Me.Width = Application.Width
Set F = Feuil2 'CodeName de la feuille de mémorisation, à adapter
Répertoire = ThisWorkbook.Path 'à adapter"
'---liste des classeurs Excel---
nf = Dir(Répertoire & "\*.xls*")
While nf <> ""
If Not nf Like "*.pdf" Then
ReDim Preserve a(1, n) 'base 0
a(0, n) = Répertoire & "\" & nf
a(1, n) = FileDateTime(a(0, n))
n = n + 1
End If
nf = Dir
Wend
'---création des fichiers PDF---
If n Then
For n = 0 To UBound(a, 2)
nf = Mid(a(0, n), InStrRev(a(0, n), "\") + 1)
If nf <> ThisWorkbook.Name Then
dat = Application.VLookup(a(0, n), F.[A:B], 2, 0)
ouvre = False
If IsError(dat) Then ouvre = True Else If dat <> a(1, n) Then ouvre = True
If ouvre Then
Application.ScreenUpdating = False
With Workbooks.Open(a(0, n))
.Sheets(1).ExportAsFixedFormat xlTypePDF, a(0, n) & ".pdf" '1ère feuille
.Close False
End With
Application.ScreenUpdating = True
End If
End If
Next
End If
'---mémorisation des classeurs Excel---
If n Then F.[A2].Resize(n, 2) = Application.Transpose(a)
F.[A2].Offset(n).Resize(Rows.Count - n - 1, 2).Delete xlUp
F.Columns("A:B").AutoFit
'---Liste des fichiers PDF---
ChoixFichier.Clear
n = 0
nf = Dir(Répertoire & "\*.pdf")
While nf <> ""
ChoixFichier.AddItem nf
nf = Dir
n = n + 1
Wend
nbFichiers = n
End Sub