Bonjour,

J'ai lu cette discussion.
je patauge aussi. Que ça soit en FtpGetFile ou en FtpPutFile, ça me retourne false.
Le Err.LastDllError me retourne l'erreur 317, mais impossible de trouver quoique ça soit à ce propos.
Alors si depuis le temps, quelqu'un a trouvé la solution je suis preneur. (Ou même si quelqu'un a une autre solution complètement différente d'ailleurs)

Mon code :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
'Envoi du fichier par FTP
Sub EnvoiSurFTP()
Dim HwndConnect
Dim HwndOpen
Dim TabChemin() As String
Chemin = ""
Rep = ThisWorkbook.Sheets(NOMFEUILLISTE).Range(CELLREP) & "\" & ThisWorkbook.Sheets(NOMFEUILAPPEL).Range(CELLBATEAU)
TabChemin = Split(Rep, "\")
For Cpt = UBound(TabChemin) To UBound(TabChemin) - 2 Step -1
    Chemin = TabChemin(Cpt) & "/" & Chemin
Next Cpt
Chemin = "/" & Left(Chemin, Len(Chemin) - 1)
'Ouvre internet
HwndOpen = InternetOpen("PutFtpFile", 1, vbNullString, vbNullString, 0) 'fonctionne
'Connection au site ftp
HwndConnect = InternetConnect(HwndOpen, SERVEURFTP, 21, LOGFTP, MDPFTP, 1, &H8000000, 0) 'fonctionne
'Création des répertoires
 
Succ = FtpCreateDirectory(HwndConnect, Chemin) 'fonctionne
'positionnement du curseur dans le répertoire
bRet = FtpSetCurrentDirectory(HwndConnect, Chemin)  'fonctionne
 'Téléchargement de test.txt
'getf = FtpGetFile(HwndConnect, "essai.txt", "D:\essai.txt", False, 0, &H0, 0) 'retourne faux
 
FilePut = FtpPutFile(HwndConnect, ThisWorkbook.Path & "\" & ThisWorkbook.name, ThisWorkbook.name, &H0, 0)  'retourne faux
If FilePut = 0 Then MsgBox TranslateWinError(Err.LastDllError, "wininet.dll"), , "Erreur dans dll wininet -> InternetConnect"
 
InternetCloseHandle HwndConnect 'Ferme la connection
InternetCloseHandle HwndOpen 'Ferme internet
End Sub