Private Sub Workbook_Open()
'chargement de tous les fichiers avec hyperliens en colonne A-B-C
Dim Repertoire As String, Nf As String, LigneColA&, LigneColB&, LigneColC&
Application.ScreenUpdating = False
Repertoire = "G:\BASE DE DONNEES\"
With Feuil1
.Cells.Clear
'ENDROIT OU SERA ECRIT LE CHEMIN DU repertoire
. [a1:c1] = Repertoire
.[a2] = "Tous les fichiers":. [b2] = "Fichiers PDF":. [c2] = "Fichiers AVI"
With .Range("A1:C2")
.Font.Bold = True: .Font.Size = 14: .HorizontalAlignment = xlCenter
.Borders.LineStyle = xlDouble 'Bordures
.Interior.Color = RGB(0, 160, 128) ' Couleur
End With
'lignes ou debuteront les listes des differentes colonnes
LigneColA = 10: LigneColB = 15: LigneColC = 20
Nf = Dir(Repertoire & "*.*") ''type de fichier a rechercher ex premier fichier xls,ou pdf ....
Do While Nf <> ""
.Hyperlinks.Add Anchor:=.Cells(LigneColA, 1), Address:=Repertoire & "\" & Nf, TextToDisplay:=Nf
LigneColA =. Cells(.Rows.Count, "A").End(xlUp).Row + 1
If UCase(Mid(Nf, InStrRev(Nf, ".") + 1)) = "PDF" Then
.Hyperlinks.Add Anchor:=.Cells(LigneColB, 2), Address:=Repertoire & "\" & Nf, TextToDisplay:=Nf
LigneColB = .Cells(.Rows.Count, "B").End(xlUp).Row + 1
End If
If UCase(Mid(Nf, InStrRev(Nf, ".") + 1)) = "AVI" Then
.Hyperlinks.Add Anchor:=.Cells(LigneColC, 3), Address:=Repertoire & "\" & Nf, TextToDisplay:=Nf
LigneColC = .Cells(.Rows.Count, "C").End(xlUp).Row + 1
End If
Nf = Dir ' fichier suivant
Loop
.Range("a10:A" & .Cells(.Rows.Count, "A").End(xlUp).Row).Sort key1:=.[a10]
.Range("b15:b" & .Cells(.Rows.Count, "b").End(xlUp).Row).Sort key1:=.[b15]
.Range("c20:c" & .Cells(.Rows.Count, "c").End(xlUp).Row).Sort key1:=.[c20]
.Columns("A:C").AutoFit
End With
Application.ScreenUpdating = True
End Sub