Den simple metode er den gode gamle - at skrive en scriptfil med kommandoerne og så kalde DOS-programmet FTP med dette script:
Public Sub RunFTP(ByVal strScriptFile As String)
' obs:
'-----------------------------
'Yes, my problem. The "command.com" was not in the path:
'
' Print Environ("path")
'
'Once I fixed that, the following procuded the expected results:
'
' Shell "command.com /c xcopy32 /? > C:\TMP\test.txt"
' Shell "start C:\TMP\test.txt"
' Kill "C:\TMP\test.txt"
'
'If you call a Win32 enabled program with Shell, it will not use the output redirection character. So the "command.com" is essential here.
'------------------------------
' Usage Example:
' call RunFTP("C:\temp\test.scr")
'
' Sample SCR File for NT/Win95 FTP
' open someftpserver.com
' anonymous
' myaccount@myrealbox.com
' lcd "c:\temp"
' cd public
' binary
' prompt
' mput *.jpg
' get myfile.txt lastfile.txt
' close
' bye
Dim strWinSysDir As String
Dim strQuote As String
Dim strMsgTitle As String
Dim strMsgPrompt As String
Dim lngMsgStyle As Long
strQuote = Chr(34)
strMsgTitle = "FTP-overførsel"
If Len(strScriptFile) = 0 Then
strMsgPrompt = "Ingen script-fil er angivet!" & vbCrLf & "Overførsel kan ikke finde sted."
lngMsgStyle = vbCritical + vbOKOnly
DoCmd.Beep
Else
If Len(Dir(strScriptFile)) = 0 Then
strMsgPrompt = "Script-filen '" & strScriptFile & "' findes ikke!" & vbCrLf & "Overførsel kan ikke finde sted."
lngMsgStyle = vbCritical + vbOKOnly
DoCmd.Beep
Else
strWinSysDir = Environ("COMSPEC")
strWinSysDir = Left(strWinSysDir, Len(strWinSysDir) - Len(Dir(strWinSysDir)))
strMsgPrompt = "Overførsel er sat i gang og kan følges i FTP-vinduet." & vbCrLf & "Tryk OK her, når den er afsluttet."
lngMsgStyle = vbExclamation + vbOKOnly
Call Shell(strWinSysDir & "ftp.exe -s:" & strQuote & strScriptFile & strQuote, vbNormalNoFocus)
End If
End If
' Pause here. Let the user wait for the FTP session to finish.
MsgBox strMsgPrompt, lngMsgStyle, strMsgTitle
End Sub
Men gode, gamle ftp.exe fungerer kun med helt simple FTP-servere. Er dit behov mere komplekst eller seriøst, vil jeg kraftigt anbefale at købe et hjælpeprogram, og her vil jeg foreslå en DLL fra MarshallSoft, som måske ikke er det billigste, du kan finde, men det virker, og der er fremragende support:
https://www.marshallsoft.com/fce4vb.htm