Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
1420to1424
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

Makro anzupassen für das 64 bit System

Makro anzupassen für das 64 bit System
09.04.2015 21:10:57
chandler

Hallo zusammen,
das folgende Makro, das in einem 32bit System unter Excel 2013 einwandfrei funktioniert,
nicht aber unter 64bit wuerde ich gerne anpassen.
https://www.herber.de/bbs/user/96987.zip
Es gibt viele Berichte bezueglich der API Anpassung im Web nachzulesen, das fachliche Wissen fehlt mir dennoch um die Tipps die darin stehen anwenden und den Code anzupassen.
Kann mir jemand dabei helfen das Modul bzw. Klasse anzupassen?
Vielen Dank im Voraus. Gruesse.

1
Beitrag zum Forumthread
Beitrag zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
Hier ein Lösungsansatz
15.04.2015 21:12:23
chandler
Hallo zusammen,
nach langer Recherche habe ich folgendes Makro fuer 64bit Excel angepasst.
Vielleicht kann das noch jemand gebrauchen.
Option Explicit
'2001 by Thomas Rodemer (autor)
'2015-15-04 by chandler update for 64bit
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 InternetCloseHandle Lib "wininet.dll" _
(ByVal hInet As Long) As Integer
Declare PtrSafe 

Function FtpSetCurrentDirectory Lib "wininet.dll" _
Alias "FtpSetCurrentDirectoryA" (ByVal hFtpSession As _
Long, ByVal lpszDirectory As String) As Long
Declare PtrSafe 

Function FtpFindFirstFile Lib "wininet.dll" _
Alias "FtpFindFirstFileA" (ByVal hFtpSession As Long, _
ByVal lpszSearchFile As String, lpFindFileData As _
WIN32_FIND_DATA, ByVal dwFlags As Long, ByVal dwContent _
As Long) As Long
Declare PtrSafe 

Function InternetFindNextFile Lib "wininet.dll" _
Alias "InternetFindNextFileA" (ByVal hFind As Long, _
lpvFindData As WIN32_FIND_DATA) As Long
Declare PtrSafe 

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 Long
Declare PtrSafe 

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 Long
Declare PtrSafe 

Function FtpDeleteFile Lib "wininet.dll" _
Alias "FtpDeleteFileA" (ByVal hFtpSession As Long, _
ByVal lpszFileName As String) As Long
Declare PtrSafe 

Function FtpRenameFile Lib "wininet.dll" _
Alias "FtpRenameFileA" (ByVal hFtpSession As Long, _
ByVal lpszFromFileName As String, ByVal lpszToFileName _
As String) As Long
Declare PtrSafe 

Function FtpCreateDirectory Lib "wininet" _
Alias "FtpCreateDirectoryA" (ByVal hFtpSession As _
Long, ByVal lpszDirectory As String) As Long
Declare PtrSafe 

Function FtpRemoveDirectory Lib "wininet" _
Alias "FtpRemoveDirectoryA" (ByVal hFtpSession As _
Long, ByVal lpszDirectory As String) As Long
Declare PtrSafe 

Function InternetGetLastResponseInfo Lib _
"wininet.dll" Alias "InternetGetLastResponseInfoA" _
(lpdwError As Long, ByVal lpszBuffer As String, _
lpdwBufferLength As Long) As Long
Const ERROR_NO_MORE_FILES = 18
Const ERROR_INTERNET_EXTENDED_ERROR = 12003
Const FTP_TRANSFER_TYPE_BINARY = &H0
Const FTP_TRANSFER_TYPE_ASCII = &H1
Const INTERNET_FLAG_PASSIVE = &H8000000
Const INTERNET_FLAG_RELOAD = &H80000000
Const INTERNET_FLAG_KEEP_CONNECTION = &H400000
Const INTERNET_FLAG_MULTIPART = &H200000
Const INTERNET_OPEN_TYPE_PRECONFIG = 0
Const INTERNET_OPEN_TYPE_DIRECT = 1
Const INTERNET_OPEN_TYPE_PROXY = 3
Const INTERNET_INVALID_PORT_NUMBER = 0
Const INTERNET_SERVICE_FTP = 1
Const INTERNET_SERVICE_GOPHER = 2
Const INTERNET_SERVICE_HTTP = 3
Declare PtrSafe 

Function FileTimeToSystemTime Lib "kernel32" _
(lpFileTime As FILETIME, lpSystemTime As SYSTEMTIME) _
As Long
Const MAX_PATH = 260
Const NO_ERROR = 0
Const FILE_ATTRIBUTE_READONLY = &H1
Const FILE_ATTRIBUTE_HIDDEN = &H2
Const FILE_ATTRIBUTE_SYSTEM = &H4
Const FILE_ATTRIBUTE_DIRECTORY = &H10
Const FILE_ATTRIBUTE_ARCHIVE = &H20
Const FILE_ATTRIBUTE_NORMAL = &H80
Const FILE_ATTRIBUTE_TEMPORARY = &H100
Const FILE_ATTRIBUTE_COMPRESSED = &H800
Const FILE_ATTRIBUTE_OFFLINE = &H1000
Private Type FILETIME
dwLowDateTime As Long
dwHighDateTime As Long
End Type
Private Type WIN32_FIND_DATA
dwFileAttributes As Long
ftCreationTime As FILETIME
ftLastAccessTime As FILETIME
ftLastWriteTime As FILETIME
nFileSizeHigh As Long
nFileSizeLow As Long
dwReserved0 As Long
dwReserved1 As Long
cFileName As String * MAX_PATH
cAlternate As String * 14
End Type
Dim Verbundenoderwas As Boolean
Private Type SYSTEMTIME
wYear As Integer
wMonth As Integer
wDayOfWeek As Integer
wDay As Integer
wHour As Integer
wMinute As Integer
wSecond As Integer
wMilliseconds As Integer
End Type

Sub ftp_download()
Dim nFlag As Long, hOpen As Long, hConnection As Long
Dim Result&
Dim strPath$, strDateiName$
Dim strUsername$, strPasswort$, strServer$, strSubDir$
strServer = "xxx.xxx.xxx.xxx"
strUsername$ = "user"
strPasswort = "user"
strSubDir$ = ""
strPath$ = IIf(Right$(ThisWorkbook.Path, 1) = "\", ThisWorkbook.Path, ThisWorkbook.Path & "\")
strDateiName$ = "test.txt"
hOpen = InternetOpen("FTP", 1, vbNullString, vbNullString, 0)
If hOpen = 0 Then
MsgBox ("A connection has not been established.")
Exit Sub
End If
hConnection = InternetConnect(hOpen, strServer, 0, strUsername, strPasswort, 1, nFlag, 0)
Result = FtpSetCurrentDirectory(hConnection, strSubDir$)
Result = FtpGetFile(hConnection, "test.txt", strPath$ & strDateiName$, False, &H0, &H0, 0)
Result = FtpPutFile(hConnection, strPath$ & strDateiName$, strDateiName$, &H0, 0)
If hConnection <> 0 Then InternetCloseHandle (hConnection)
If hOpen <> 0 Then InternetCloseHandle (hOpen)
End Sub

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige