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 :

Problèmes charger fichier sur FTP [XL-2010]


Sujet :

Macros et VBA Excel

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Candidat au Club
    Inscrit en
    Juin 2010
    Messages
    2
    Détails du profil
    Informations forums :
    Inscription : Juin 2010
    Messages : 2
    Par défaut Problèmes charger fichier sur FTP
    Bonjour à tous
    Je vais passer sur excel 2010 64 bits.
    J'ai une macro pour uploader un fichier sur un FTP. Cette macro ne veut pas fonctionner sur la version 2010 j'ai une alerte : "le code contenu dans ce projet doit être mis à jour pour pouvoir etre utilisé sur les systemes 64 bits.Vérifiez et mettre à jour les instructions Declare puis marquez-les avec l'attribut PtrSafe."
    Bon, là je séche..
    Quelqu'un pourrait-il m'aider SVP; cela fait maintenant une semaine que je fouille les forum sans succes ...

    Ci dessous mon code (version 2003)

    MERCI aux bonnes volontés

    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
    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
    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
    Declare Function FtpSetCurrentDirectory Lib "wininet.dll" Alias _
         "FtpSetCurrentDirectoryA" (ByVal hFtpSession As Long, _
         ByVal lpszDirectory As String) As Boolean
    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
     
    Sub chargefichier()
    Internet_OK = InternetOpen("", 1, "", "", 0)
    If Internet_OK Then
    FTP_OK = InternetConnect(Internet_OK, "ftp.ici.ici", 21, "login", "motdepasse", 1, 0, 0)
    If FtpSetCurrentDirectory(FTP_OK, "/") Then
     
    succès = FtpGetFile(FTP_OK, "Journalier.xls", "T:\XXXX\YYYY\ZZZZ\monfichier.xls", False, 0, &H0, 0)
    End If
    End If
    If succès Then 'je travail'
    End Sub

  2. #2
    Expert éminent


    Profil pro
    Inscrit en
    Juin 2003
    Messages
    14 008
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2003
    Messages : 14 008
    Par défaut
    bonjour,

    essai :

    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
     
    #If Vba7 Then 
    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
    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
    Declare PtrSafe Function FtpSetCurrentDirectory Lib "wininet.dll" Alias _
         "FtpSetCurrentDirectoryA" (ByVal hFtpSession As Long, _
         ByVal lpszDirectory As String) As Boolean
    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
     
    #Else 
    eclare 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
    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
    Declare Function FtpSetCurrentDirectory Lib "wininet.dll" Alias _
         "FtpSetCurrentDirectoryA" (ByVal hFtpSession As Long, _
         ByVal lpszDirectory As String) As Boolean
    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
    #EndIf

  3. #3
    Candidat au Club
    Inscrit en
    Juin 2010
    Messages
    2
    Détails du profil
    Informations forums :
    Inscription : Juin 2010
    Messages : 2
    Par défaut Problèmes charger fichier FTP
    Bonjour,
    MERCI bbil
    Grace à vous tout fonctionne trés bien...
    Ci dessous je poste ma macro (testée ce matin avec succés sur 2010)
    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
    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
    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
    Declare PtrSafe Function FtpSetCurrentDirectory Lib "wininet.dll" Alias _
         "FtpSetCurrentDirectoryA" (ByVal hFtpSession As Long, _
         ByVal lpszDirectory As String) As Boolean
    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
     
    Sub chargefichier()
    Internet_OK = InternetOpen("", 1, "", "", 0)
    If Internet_OK Then
    FTP_OK = InternetConnect(Internet_OK, "ftp.ici.ici", 21, "login", "motdepasse", 1, 0, 0)
    If FtpSetCurrentDirectory(FTP_OK, "/") Then
     
    succès = FtpGetFile(FTP_OK, "Journalier.xls", "T:\XXXX\YYYY\ZZZZ\monfichier.xls", False, 0, &H0, 0)
    End If
    End If
    If succès Then 'je travail'
    End Sub
    Je trouves que c'est trés sympas que des gens se penchent sur votre problème pour en aider d'autres.
    Longue vie aux FORUMS..

    Encore MERCI
    Bonne journée à tous

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [FTP] Récupération taille fichier sur ftp
    Par Kerod dans le forum Langage
    Réponses: 4
    Dernier message: 18/04/2006, 03h18
  2. envoyer un fichier sur ftp
    Par alex01pernot dans le forum Web & réseau
    Réponses: 3
    Dernier message: 26/03/2006, 18h22
  3. [Upload] upload fichier sur ftp free
    Par Halukard dans le forum Langage
    Réponses: 61
    Dernier message: 12/02/2006, 20h50
  4. IdFTP : Récupération d'un fichier sur ftp ?
    Par MaTHieU_ dans le forum C++Builder
    Réponses: 5
    Dernier message: 29/11/2005, 13h15
  5. [C#] [FTP] Envoi et suppression fichier sur ftp NON ANONYME!
    Par djsbens dans le forum Windows Forms
    Réponses: 14
    Dernier message: 30/03/2005, 10h20

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