Option Explicit
' Requires references to Microsoft Shell Controls and Automation
Public Sub Example_Ter()
Dim myFolderItem As FolderItem
Dim i&
i = 2
[A1:E1] = Array("Nom Fichier", "Date modif", "Chemin", "Type", "Taille")
For Each myFolderItem In ftpList("speedtest.tele2.net/upload", "anonymous", "anonymous") ' username: anonymous, password: anonymous
'Debug.Print myFolderItem.Name, myFolderItem.IsFolder ' demo
Cells(i, 1) = myFolderItem.Name
Cells(i, 2) = myFolderItem.ModifyDate
Cells(i, 3) = myFolderItem.Path
Cells(i, 4) = myFolderItem.Type
Cells(i, 5) = myFolderItem.Size
i = i + 1
Next
End Sub
' Returns a FolderItems collection from the FTP server
Private Function ftpList(strFTPlocation As String, Optional strUser As String, Optional strPassword As String) As FolderItems
Dim myShell As New Shell
Dim strConnect As String
If strUser <> "" Then strConnect = strUser & ":" & strPassword & "@"
Set ftpList = myShell.Namespace("FTP://" & strConnect & strFTPlocation).Items '("ftp://user:password@ftp.site.com")
End Function