Bonjour à tous,
J'essaye de déposer par macro un fichier sur un serveur FTP en utilisant Filezilla. Je me connecte bien au serveur mais j'ai une erreur à la partie dépôt de fichier (LPRT) :
CONSOLE FILEZILLA :
- [Command] USER testic
- [Response] 331 Please, specify the password.
- [Command] PASS ****
- [Response] 230 Login successful.
- [Command] CWD /
- [Response] 250 CWD command successful
- [Command] TYPE I
- [Response] 200 Type set to I
- [Command] LPRT 6,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,248,6
- [Response] 500 Wrong command.
LES FONCTIONS VBA (en rouge la fonction FtpPutFile qui pose souci) :
LA MACRO (en rouge la partie ko) :
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 Private Declare PtrSafe Function InternetCloseHandle Lib "wininet.dll" _ (ByVal hInet As Long) As Integer Private Declare PtrSafe Function InternetConnect Lib "wininet.dll" Alias "InternetConnectA" _ (ByVal hInternetSession As Long, ByVal sServerName As String, _ ByVal nServerPort As Integer, _ ByVal sUserName As String, ByVal sPassword As String, ByVal lService As Long, _ ByVal lFlags As Long, ByVal lContext As Long) As Long Private Declare PtrSafe Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" _ (ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String, _ ByVal sProxyBypass As String, ByVal lFlags As Long) As Long Private Declare PtrSafe Function FtpSetCurrentDirectory Lib "wininet.dll" Alias _ "FtpSetCurrentDirectoryA" (ByVal hFtpSession As Long, _ ByVal lpszDirectory As String) As Boolean Private Declare PtrSafe Function FtpGetFile Lib "wininet.dll" Alias "FtpGetFileA" _ (ByVal hConnect As Long, ByVal lpszRemoteFile As String, _ ByVal lpszNewFile As String, ByVal fFailIfExists As Long, _ ByVal dwFlagsAndAttributes As Long, ByVal dwFlags As Long, _ ByRef dwContext As Long) As Boolean Private Declare PtrSafe Function FtpPutFile Lib "wininet.dll" Alias _ "FtpPutFileA" (ByVal hConnect As Long, ByVal lpszLocalFile As String, _ ByVal lpszNewRemoteFile As String, ByVal dwFlags As Long, _ ByVal dwContext As Long) As Boolean
AUTRES INFOS :
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'Envoi et réception d'un fichier Private Sub Commande27_Click() Dim HwndConnect As Long Dim HwndOpen As Long 'Ouvre internet HwndOpen = InternetOpen("SiteWeb", 0, vbNullString, vbNullString, 0) 'Connection au site ftp HwndConnect = InternetConnect(HwndOpen, "127.0.0.1", 21, _ "testic", "<MDP>", 1, 0, 0) 'positionnement du curseur dans le répertoire FtpSetCurrentDirectory HwndConnect, "/" 'Téléchargement de test.txt FtpGetFile HwndConnect, "test.txt", "C:\Users\jerem\Desktop\Test.txt", _ False, 0, &H0, 0 FtpPutFile HwndConnect, "C:\Users\jerem\Desktop\Test.txt", "test.txt", &H0, 0 'Envoi du fichier test.txt en le renommant shwin.txt sur le serveur InternetCloseHandle HwndConnect 'Ferme la connection InternetCloseHandle HwndOpen 'Ferme internet End Sub
En essayant de déposer des fichiers xlsx ou xlsm, ça ne fonctionnait pas mais je n'avais même pas l'étape "LPRT". Avec un fichier texte, j'accède au moins à la suite mais sans succès. J'ai essayé plein de fichiers, j'ai essayé de déposer le fichier sans passer par la macro sans souci.
Bref je n'ai plus d'idée, si vous en avez je suis preneur !
Merci d'avance !







Répondre avec citation



Partager