IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Macros et VBA Excel Discussion :

Impossible de télécharger un fichier en FTP


Sujet :

Macros et VBA Excel

  1. #1
    Futur Membre du Club
    Profil pro
    Inscrit en
    Janvier 2013
    Messages
    104
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2013
    Messages : 104
    Points : 6
    Points
    6
    Par défaut Impossible de télécharger un fichier en FTP
    Bonjour

    J'ai récupéré le code envoi et réception de fichier en FTP dans la (FAQ http://access.developpez.com/sources...hiers#EnvoiFTP) mais le téléchargement se fait pas..

    Plus précisément, j'ai créer un bouton sous excel et je l'ai affecté a une macro. Dans cette macro j'ai mis le code ci-dessous

    Pouvez vous me dire si il y a des erreurs lorsque je l'ai adapté ?

    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
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    Private Declare Function InternetCloseHandle Lib "wininet.dll" _
      (ByVal hInet As Long) As Integer
     
    Private Declare 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 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 Function FtpSetCurrentDirectory Lib "wininet.dll" Alias _
    "FtpSetCurrentDirectoryA" (ByVal hFtpSession As Long, _
    ByVal lpszDirectory As String) As Boolean
     
    Private Declare 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 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
     
    Sub Bouton1_Clic()
    Dim HwndConnect As Long
    Dim HwndOpen As Long
    'Ouvre internet
    HwndOpen = InternetOpen("SiteWeb", 0, vbNullString, vbNullString, 0)
    'Connection au site ftp
    HwndConnect = InternetConnect(HwndOpen, "ftp.olympe.in", 22, _
      "Mon-Identifiant", "Mon-MDP", 1, 0, 0)
    'positionnement du curseur dans le répertoire
    FtpSetCurrentDirectory HwndConnect, "Mon-Identifiant.olympe.in/"
     'Téléchargement de test.txt
    FtpGetFile HwndConnect, "test.exe", "C:\Users\pat\Desktop\", _
      False, 0, &H0, 0
     
    InternetCloseHandle HwndConnect 'Ferme la connection
    InternetCloseHandle HwndOpen 'Ferme internet
     
    End Sub

  2. #2
    Expert éminent
    Avatar de hackoofr
    Homme Profil pro
    Enseignant
    Inscrit en
    Juin 2009
    Messages
    3 839
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Juin 2009
    Messages : 3 839
    Points : 9 222
    Points
    9 222

  3. #3
    Futur Membre du Club
    Profil pro
    Inscrit en
    Janvier 2013
    Messages
    104
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2013
    Messages : 104
    Points : 6
    Points
    6
    Par défaut
    Merci ça fonctionne niquel mais en fait je veux le faire en vba pour pouvoir faire une macro excel..

Discussions similaires

  1. [FTP] Télécharger un fichier par FTP
    Par jerome38000 dans le forum Langage
    Réponses: 5
    Dernier message: 27/05/2011, 15h41
  2. Impossible de télécharger un fichier
    Par mioux dans le forum IIS
    Réponses: 1
    Dernier message: 24/11/2008, 15h54
  3. [FTP] Impossible de supprimer mes fichiers sur FTP
    Par Invité dans le forum Langage
    Réponses: 6
    Dernier message: 24/04/2008, 09h16
  4. Impossible de télécharger des fichiers depuis mon serveur
    Par amine55555 dans le forum Mode d'emploi & aide aux nouveaux
    Réponses: 1
    Dernier message: 12/05/2007, 14h15
  5. Impossible de Télécharger les fichiers joints
    Par Rabie de OLEP dans le forum Internet
    Réponses: 1
    Dernier message: 27/04/2007, 10h17

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo