Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
1048to1052
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Inhaltsverzeichnis

Aktuelle Mappe auf Ftp server Uploaden/Speichern?

Aktuelle Mappe auf Ftp server Uploaden/Speichern?
10.02.2009 18:32:56
Tobias
Ich suche nach einem Script, mit dem man die aktuelle Mappe auf einem
FTP server (mit passwort) speichern kann.
Das script von Leith Ross sah mir schon vielversprechend aus...
ich bekomme aber die Fehlermeldung: "Mehrfachdekleration im aktuellen Gültigkeitsbereich"
in der Zeile: Dim hostFile As String
Hat jemand ne Idee, bzw. gibts nen anderen Ansatz?
'Written: June 11, 2008
'Author: Leith Ross
'Open the Internet object
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
'Connect to the network
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
'Get a file using FTP
Private Declare 

Function FtpGetFile _
Lib "wininet.dll" _
Alias "FtpGetFileA" _
(ByVal hFtpSession As Long, _
ByVal lpszRemoteFile As String, _
ByVal lpszNewFile As String, _
ByVal fFailIfExists As Boolean, _
ByVal dwFlagsAndAttributes As Long, _
ByVal dwFlags As Long, _
ByVal dwContext As Long) As Boolean
'Send a file using FTP
Private Declare 

Function FtpPutFile _
Lib "wininet.dll" _
Alias "FtpPutFileA" _
(ByVal hFtpSession As Long, _
ByVal lpszLocalFile As String, _
ByVal lpszRemoteFile As String, _
ByVal dwFlags As Long, _
ByVal dwContext As Long) As Boolean
'Close the Internet object
Private Declare 

Function InternetCloseHandle _
Lib "wininet.dll" _
(ByVal hInet As Long) As Integer


Sub UploadFTP()
'When uploading a file, make sure you have permisson to create a file on the server.
'The size limit for a uploading a file is 4GB.
Dim hostFile As String
Dim INet As Long
Dim INetConn As Long
Dim hostFile As String
Dim Password As String
Dim RetVal As Long
Dim ServerName As String
Dim Success As Long
Dim UserName As String
Const ASCII_TRANSFER = 1
Const BINARY_TRANSFER = 2
ServerName = "ftp.subnet.at"
UserName = "xyz"
Password = "xyz"
'localFile = "C:\My Documents\Test.Txt"  beliebiges File Als Quelle
localFile = ThisWorkbook.FullName          'Diese xls als Quelle
hostFile = "\\whatever.xls"                     ' Ziel
RetVal = False
INet = InternetOpen("MyFTP Control", 1&, vbNullString, vbNullString, 0&)
If INet > 0 Then
INetConn = InternetConnect(INet, ServerName, 0&, UserName, Password, 1&, 0&, 0&)
If INetConn > 0 Then
Success = FtpPutFile(INetConn, localFile, hostFile, BINARY_TRANSFER, 0&)
RetVal = InternetCloseHandle(INetConn)
End If
RetVal = InternetCloseHandle(INet)
End If
If Success  0 Then
MsgBox ("Upload process completed")
Else
MsgBox "FTP File Error!"
End If
End Sub


4
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Aktuelle Mappe auf Ftp server Uploaden/Speichern?
10.02.2009 18:58:53
Horst
hast du zufällig auch ein Skript zum Download einer .xls von einem FTP-Server?
AW: Aktuelle Mappe auf Ftp server Uploaden/Speichern?
10.02.2009 21:30:00
Ramses
Hallo
Wenn es nur daran liegt, bei EXCEL GUT sollte man doch lesen können
Dim hostFile As String
Dim INet As Long
Dim INetConn As Long
Dim hostFile As String
Aus der Upload-Sequenz einfach einen der beiden Einträge entfernen.
Gruss Rainer
AW: Aktuelle Mappe auf Ftp server Uploaden/Speichern?
10.02.2009 22:08:00
Tobias
@ Horst
Hab ich leider nicht, hab bei der Recherche aber so etwas gesehen... wenn ich es wieder finde,
poste ich es hier.
@Ramses
Vielen Dank - Mein Gehirn ist sehr schlecht im Entdecken von doppelten Einträgen - ist mir schon mal passiert ;)
Allerdings funkt es trotzdem nicht :(
Hab die ftp einstellungen mehrmals überprüft, daten sind alle korrekt...
habs auch mit anderen dateien versucht als mit dem offenen arbeitsblatt (für den upload)
klappt aber nicht: "FTP File Error"
Anzeige
AW: Aktuelle Mappe auf Ftp server Uploaden/Speichern?
10.02.2009 22:40:00
Ramses
Hallo
Probier mal was ganz einfaches.
Setzt allerdings voraus, dass du online bist
Sub myFTP_Upload()
    Open "c:\login.txt" For Output As #1
    'User
    Print #1, "Username" 'Worksheets("tabelle1").[A1]
    'Passwort
    Print #1, "Password" 'Worksheets("tabelle1").[A2]
    'TargetDirectory, z.B. /
    Print #1, "cd " & "FTP://www.office.gmxhome.de/ftpupload" 'Worksheets("tabelle1").[A3]
    'Uploadtype
    Print #1, "ascii" '"binary"
    'Upload File
    Print #1, "put " & "C:\Upload.xls" 'Worksheets("tabelle1").[A4]
    'Connection clos
    Print #1, "bye" '"quit"
    Close #1
    'Start FTP Upload
    Shell "ftp -d -s:c:\login.txt ", vbNormalFocus 'vbHide
    Kill "c:\login.txt"
End Sub

Gruss Rainer
Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige