Private Sub UserForm_Initialize()
Dim nf$, a$(), n%
Me.Height = Application.Height
Me.Width = Application.Width
Répertoire = ThisWorkbook.Path 'à adapter
'---liste des classeurs Excel---
nf = Dir(Répertoire & "\*.xls*")
While nf <> ""
ReDim Preserve a(1, n) 'base 0
a(0, n) = Répertoire & "\" & nf
a(1, n) = Répertoire & "\" & Left(nf, InStrRev(nf, ".")) & "pdf"
n = n + 1
nf = Dir
Wend
'---création des fichiers PDF---
For n = 0 To UBound(a, 2)
If a(0, n) <> ThisWorkbook.FullName And Dir(a(1, n)) = "" Then
Application.ScreenUpdating = False
With Workbooks.Open(a(0, n))
.Sheets(1).ExportAsFixedFormat xlTypePDF, a(1, n) '1ère feuille
.Close False
End With
Application.ScreenUpdating = True
End If
Next
'---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
Private Sub UserForm_Initialize()
Dim nf$, a$(), n%
Me.Height = Application.Height
Me.Width = Application.Width
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(n) 'base 0
a(n) = Répertoire & "\" & nf
n = n + 1
End If
nf = Dir
Wend
'---création des fichiers PDF---
If n Then
For n = 0 To UBound(a)
nf = Mid(a(n), InStrRev(a(n), "\") + 1)
If nf <> ThisWorkbook.Name And Dir(a(n) & ".pdf") = "" Then
Application.ScreenUpdating = False
With Workbooks.Open(a(n))
.Sheets(1).ExportAsFixedFormat xlTypePDF, a(n) & ".pdf" '1ère feuille
.Close False
End With
Application.ScreenUpdating = True
End If
Next
End If
'---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
Private Sub UserForm_Initialize()
Dim nf$, a$(), n%
Me.Height = Application.Height
Me.Width = Application.Width
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(n) 'base 0
a(n) = Répertoire & "\" & nf
n = n + 1
End If
nf = Dir
Wend
'---création des fichiers PDF---
If n Then
Application.ScreenUpdating = False
For n = 0 To UBound(a)
nf = Mid(a(n), InStrRev(a(n), "\") + 1)
If nf <> ThisWorkbook.Name Then
With Workbooks.Open(a(n))
.Sheets(1).ExportAsFixedFormat xlTypePDF, a(n) & ".pdf" '1ère feuille
.Close False
End With
End If
Next
Application.ScreenUpdating = True
End If
'---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
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
Private Sub UserForm_Initialize()
Dim F As Worksheet, rep$, d As Object, nf$, a$(), n&, t, i&, x$, b
Me.Height = Application.Height
Me.Width = Application.Width
Set F = Feuil2 'CodeName de la feuille de mémorisation, à adapter
Répertoire = ThisWorkbook.Path 'à adapter
rep = Répertoire & "\"
'---liste des classeurs Excel---
Set d = CreateObject("Scripting.Dictionary")
d.CompareMode = vbTextCompare 'la casse est ignorée
nf = Dir(rep & "*.xls*")
While nf <> ""
If Not nf Like "*.pdf" And Not nf = ThisWorkbook.Name Then
ReDim Preserve a(1, n) 'base 0
a(0, n) = rep & nf
a(1, n) = FileDateTime(a(0, n))
d(a(0, n) & Chr(1) & a(1, n)) = ""
n = n + 1
End If
nf = Dir
Wend
'---repérage des classeurs modifiés---
t = F.[A2].CurrentRegion.Resize(, 2)
For i = 1 To UBound(t)
x = t(i, 1) & Chr(1) & t(i, 2)
If d.exists(x) Then d.Remove x
Next
'---création des fichiers PDF---
If d.Count Then
b = d.keys
Application.ScreenUpdating = False
For i = 0 To UBound(b)
x = Split(b(i), Chr(1))(0)
With Workbooks.Open(x)
.Sheets(1).ExportAsFixedFormat xlTypePDF, x & ".pdf" '1ère feuille
.Close False
End With
Next
Application.ScreenUpdating = True
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(rep & "*.pdf")
While nf <> ""
ChoixFichier.AddItem nf
nf = Dir
n = n + 1
Wend
nbFichiers = n
End Sub
peux ton avoir le fichier en premier plan
Private Sub Image3_Click() 'logo Excel
Dim x$
If Not FichierChoisi Like "*?.pdf" Then Exit Sub
x = Left(FichierChoisi, Len(FichierChoisi) - 4)
On Error Resume Next
If IsError(Workbooks(x)) Then
UserForm1.Show
If mdp Then Workbooks.Open Répertoire & "\" & x
Else
Workbooks(x).Activate
End If
End Sub
If Répertoire = "" Then Répertoire = ThisWorkbook.Path 'à adapter
If IsNull(ChoixFichier) Then Exit Sub
Private Sub Workbook_Activate()
afficheform
End Sub
Private Sub Workbook_Deactivate()
F_ListeFichiersRep.Hide
End Sub