PDA

View Full Version : VBA FTP help



drrat
11-25-2010, 10:21 AM
VBA question: -

If I can connect via an ftp client (ie explorer) with the details I add to this code, why does internetconnect always return zero!

'========================
Private Const MAX_PATH = 260

Private Type FILETIME
dwLowDateTime As Long
dwHighDateTime As Long
End Type

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 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 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


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



Sub test()

Dim pData As WIN32_FIND_DATA

lngINet = InternetOpen("MyFTP Control", 1, vbNullString, vbNullString, 0)
lngINetConn = InternetConnect(lngINet, "ftp://ftpaddress", 21, "username", "password", 1, 0, 0)
lngHINet = FtpFindFirstFile(lngINetConn, "*.*", pData, 0, 0)

End Sub
'===================================

Any help here would be appreciated!

Thanks,

Jason

orange
11-25-2010, 02:45 PM
See if this helps

http://www.tek-tips.com/faqs.cfm?fid=5904

or

http://bytes.com/topic/access/answers/199797-ftp-ms-access

or

http://www.zbconsulting.eu/?tabid=58