Sub chercherfichier()
Dim lefichier As FileDialog
Dim trouvenom As Variant
Set lefichier = Application.FileDialog(msoFileDialogFilePicker)
With lefichier
If .Show <> -1 Then
GoTo vide
End If
Range("i3") = .SelectedItems(1)
End With
trouvenom = VBA.Split(lefichier.SelectedItems(1), "\")
Range("i2") = trouvenom(UBound(trouvenom))
Exit Sub
vide:
End Sub
Sub placerdansdb()
Dim dl As Long
Dim ligne As Long
If Range("i2") <> Empty And Range("i3") <> Empty Then
'eviter les doublons
For ligne = 6 To Range("h5").End(xlDown).Row
If Range("h" & ligne) = Range("i2") Then
MsgBox "le fichier existe déga"
Exit Sub
End If
Next ligne
'controler
If Range("h6") <> Empty Then
ActiveSheet.ListObjects(1).ListRows.Add
dl = Range("h5").End(xlDown).Row + 1
Else
dl = 6
End If
Range("h" & dl) = Range("i2")
Range("i" & dl) = Range("i3")
Range("i2") = Empty
Range("i3") = "=IFERROR(VLOOKUP(I2,Tableau1,2,0)," & Chr(34) & Chr(34) & ")"
End If
End Sub
Sub ouvrirfichier()
Range("i3") = "=IFERROR(VLOOKUP(I2,Tableau1,2,0)," & Chr(34) & Chr(34) & ")"
Application.DisplayAlerts = False
ActiveWorkbook.FollowHyperlink Address:=Range("i3")
End Sub