Home  |   French  |   About  |   Search  | mvps.org  

What's New
Table Of Contents
Credits
Netiquette
10 Commandments 
Bugs
Tables
Queries
Forms
Reports
Modules
APIs
Strings
Date/Time
General
Downloads
Resources
Search
Feedback
mvps.org

In Memoriam

Terms of Use


VB Petition

Modules: Use FTP

Author(s)
Dev Ashish

(Q)    How can I use FTP from Access?

(A)     With Win95 and NT, you need to use a SCR (script) file with FTP. Consider this sample sub:

'******* Code Start *****
'This code was originally written by Dev Ashish
'It is not to be altered or distributed,
'except as part of an application.
'You are free to use it in any application,
'provided the copyright notice is left unchanged.
'
'Code Courtesy of
'Dev Ashish
'
Sub sFTP(stSCRFile As String)
'Usage Example:
'   call sFTP("C:\temp\test.scr")
'Sample SCR File for NT/Win95 FTP
'   lcd "c:\temp"
'   open ftp.someserver.com
'   anonymous
'   dash10@hotmail.com
'   cd public
'   binary
'   get dead.letter dead.letter
'   bye

Dim stSysDir As String
    stSysDir = Environ$("COMSPEC")
    stSysDir = Left$(stSysDir, Len(stSysDir) - Len(Dir(stSysDir)))
    Call Shell(stSysDir & "ftp.exe -s:" & stSCRFile, vbNormalFocus)
End Sub
'********** Code End *******

We need to pass FTP.EXE as the program name, not CMD.EXE (under NT) which Environ$("Comspec") returns. If you want the Dos window to be hidden, you can use vbHide instead of vbNormalFocus.

Another alternative, which requires you to have Internet Explorer 4.x or better installed, is to use the WinInet APIs directly. Sample classes are available in  Internet Transfer Library.


1998-2010, Dev Ashish & Arvin Meyer, All rights reserved. Optimized for Microsoft Internet Explorer