469,343 Members | 5,380 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,343 developers. It's quick & easy.

FTP from MS Access?

How can one FTP to one's site via VBA (or built in Access control)? Examples
of required funtions would be: file upload, download, delete, rename, move,
and director listing.

Thanks in advance
Nov 13 '05 #1
16 14349
This is what I use:

Option Compare Database
Option Explicit
Private Const ModEro = 9100

Public Function FTP(ascii As Boolean, send As Boolean, pathname As String,
FileName As String, server As String, serverpathname As String,
serverfilename As String, username As String, password As String, Optional
RstN As String, Optional RstFld As String)
Dim Fs As Object
Dim a As Variant
Dim RST As Recordset
Const script = "__temp_script.tmp"
'---
Dim asciiType As String
If ascii = True Then asciiType = "ascii" Else asciiType = "binary"
'---
Dim SendType As String
If send = True Then SendType = "Put " Else SendType = "Get "
'---create and open the file
Set Fs = CreateObject("Scripting.FileSystemObject")
Set a = Fs.CreateTextFile(pathname & "\" & script, True)
' write all the lines to the file
a.writeline "lcd " & Chr(34) & pathname & Chr(34)
a.writeline "open " & server
a.writeline username
a.writeline password
If (serverpathname <> "") Then a.writeline "cd " & serverpathname
If (ascii) Then
a.writeline asciiType
Else
a.writeline asciiType
End If
If RstN <> "" Then
Set RST = CurrentDb.OpenRecordset(RstN)
Do While Not RST.EOF
FileName = RST.Fields(RstFld) & ".html"
serverfilename = FileName
a.writeline SendType & FileName & " " & serverfilename
RST.MoveNext
Loop
Else
a.writeline SendType & FileName & " " & serverfilename
End If
a.writeline "bye"
'close file
a.Close
sFTP (pathname & "\" & script)
End Function

Private Sub sFTP(stSCRFile As String)
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

Nov 13 '05 #2
On Mon, 02 Aug 2004 02:57:55 GMT, "tekknow"
<te****************@hotmail.com> wrote:

Check out the wininet DLL, e.g. at
http://msdn.microsoft.com/library/de..._reference.asp.
It provides FTP and more without running ugly command-line windows.

-Tom.

How can one FTP to one's site via VBA (or built in Access control)? Examples
of required funtions would be: file upload, download, delete, rename, move,
and director listing.

Thanks in advance


Nov 13 '05 #3
"tekknow" <te****************@hotmail.com> wrote:
How can one FTP to one's site via VBA (or built in Access control)? Examples
of required funtions would be: file upload, download, delete, rename, move,
and director listing.


Microsoft Access & TCP/IP programming
<...>
Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
<....>
Nov 13 '05 #4
RE/
How can one FTP to one's site via VBA (or built in Access control)? Examples
of required funtions would be: file upload, download, delete, rename, move,
and director listing.


One thing to watch for: Proxies. Your code has to be different depending on
whether the app is going through a proxy or not. That drove me nuts for a
couple days until I finally caught on.
--
PeteCresswell
Nov 13 '05 #5
Tony Toews <tt****@telusplanet.net> wrote in message news:<3j********************************@4ax.com>. ..
"tekknow" <te****************@hotmail.com> wrote:
How can one FTP to one's site via VBA (or built in Access control)? Examples
of required funtions would be: file upload, download, delete, rename, move,
and director listing.


Microsoft Access & TCP/IP programming
<...>

Tony


Tony,

Nice information. The fifth link is broken though.

http://www.planet-source-code.com/xq...s/ShowCode.htm

James A. Fortune
Nov 13 '05 #6
On Mon, 02 Aug 2004 02:57:55 GMT, "tekknow"
<te****************@hotmail.com> wrote:
How can one FTP to one's site via VBA (or built in Access control)? Examples
of required funtions would be: file upload, download, delete, rename, move,
and director listing.

Thanks in advance

Give this a try...

http://www.mvps.org/access/modules/mdl0037.htm

I have had good luck with the class in A97, I haven't tried it in
others.

- Jim
Nov 13 '05 #7
"(Pete Cresswell)" <x@y.z> wrote:
How can one FTP to one's site via VBA (or built in Access control)? Examples
of required funtions would be: file upload, download, delete, rename, move,
and director listing.


One thing to watch for: Proxies. Your code has to be different depending on
whether the app is going through a proxy or not. That drove me nuts for a
couple days until I finally caught on.


Thanks for the warning. I'll be working on some similar code soon.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Nov 13 '05 #8
Thanks, this will work for Put and Get, bt, I'll still need to research
directory listings and renames.

Incidentally, in order to use filenames with spaces, this line:
a.writeline SendType & FileName & " " & serverfilename

had to be changed to read thus:
a.writeline SendType & """" & FileName & """" & " " & """" &
serverfilename & """"

Thanks again.
"WindAndWaves" <ac****@ngaru.com> wrote in message
news:nJ*******************@news.xtra.co.nz...
This is what I use:

Option Compare Database
Option Explicit
Private Const ModEro = 9100

Public Function FTP(ascii As Boolean, send As Boolean, pathname As String,
FileName As String, server As String, serverpathname As String,
serverfilename As String, username As String, password As String, Optional
RstN As String, Optional RstFld As String)
Dim Fs As Object
Dim a As Variant
Dim RST As Recordset
Const script = "__temp_script.tmp"
'---
Dim asciiType As String
If ascii = True Then asciiType = "ascii" Else asciiType = "binary"
'---
Dim SendType As String
If send = True Then SendType = "Put " Else SendType = "Get "
'---create and open the file
Set Fs = CreateObject("Scripting.FileSystemObject")
Set a = Fs.CreateTextFile(pathname & "\" & script, True)
' write all the lines to the file
a.writeline "lcd " & Chr(34) & pathname & Chr(34)
a.writeline "open " & server
a.writeline username
a.writeline password
If (serverpathname <> "") Then a.writeline "cd " & serverpathname
If (ascii) Then
a.writeline asciiType
Else
a.writeline asciiType
End If
If RstN <> "" Then
Set RST = CurrentDb.OpenRecordset(RstN)
Do While Not RST.EOF
FileName = RST.Fields(RstFld) & ".html"
serverfilename = FileName
a.writeline SendType & FileName & " " & serverfilename
RST.MoveNext
Loop
Else
a.writeline SendType & FileName & " " & serverfilename
End If
a.writeline "bye"
'close file
a.Close
sFTP (pathname & "\" & script)
End Function

Private Sub sFTP(stSCRFile As String)
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

Nov 13 '05 #9
Looks like everything I need, short of the aspirin. I'll keep this in mind,
but it's a bit more intense than I hoped for. Then again, learning is always
a good thing (as long as your learning a good thing ;-)

Thanks again

"Tom van Stiphout" <no*************@cox.net> wrote in message
news:il********************************@4ax.com...
On Mon, 02 Aug 2004 02:57:55 GMT, "tekknow"
<te****************@hotmail.com> wrote:

Check out the wininet DLL, e.g. at
http://msdn.microsoft.com/library/de..._reference.asp. It provides FTP and more without running ugly command-line windows.

-Tom.

How can one FTP to one's site via VBA (or built in Access control)? Examplesof required funtions would be: file upload, download, delete, rename, move,and director listing.

Thanks in advance


Nov 13 '05 #10
I haven't even checked these out yet, but coming from you,I"m sure there's
great info here. I'll be doing some reading this week, I can see.

Thanks a million for the links.
"Tony Toews" <tt****@telusplanet.net> wrote in message
news:3j********************************@4ax.com...
"tekknow" <te****************@hotmail.com> wrote:
How can one FTP to one's site via VBA (or built in Access control)? Examplesof required funtions would be: file upload, download, delete, rename, move,and director listing.


Microsoft Access & TCP/IP programming
<...>

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
<...>
Nov 13 '05 #11
Dear TekMaster

I think you are in the same boat as I am, keeping it simple - as long as it
works then that is great.

I would prefer to use some of the other options listed by the other users,
but they seem a lot harder to implement and more importantly, less portable.
If you type FTP in the windows run prompt and then from the prompt type
help, then you get all the commands that are available.

you can then type help close, for example, to find out about the close
command.

Thanks also for your
Nov 13 '05 #12
tekknow wrote:
Thanks, this will work for Put and Get, bt, I'll still need to research
directory listings and renames.


You can use the same sort of thing, just write out the script file,
execute it like:

Shell "ftp -s MyScript.ftp > output.txt"

You can then read the output.txt file, I use this a lot, my first error
check is to look for lines with val() >499 as these are errors. In this
way I also check (using ls) for files already existing on the FTP server.

--
Error reading sig - A)bort R)etry I)nfluence with large hammer
Nov 13 '05 #13
Thanks a bunch, Trevor, I was not sure how to output a log file. I'll be
playing with this for a while, for sure.

Thanks again.

"Trevor Best" <nospam@localhost> wrote in message
news:41**********************@auth.uk.news.easynet .net...
tekknow wrote:
Thanks, this will work for Put and Get, bt, I'll still need to research
directory listings and renames.


You can use the same sort of thing, just write out the script file,
execute it like:

Shell "ftp -s MyScript.ftp > output.txt"

You can then read the output.txt file, I use this a lot, my first error
check is to look for lines with val() >499 as these are errors. In this
way I also check (using ls) for files already existing on the FTP server.

--
Error reading sig - A)bort R)etry I)nfluence with large hammer

Nov 13 '05 #14
I think the only thing I don't like about this is the command prompt, which
may confuse the user (this is for one of my kids, actually).

Thanks for your assist, though. I am using our code for now, since I have no
time to learn the fancy stuff right now.
"WindAndWaves" <ac****@ngaru.com> wrote in message
news:UW*******************@news.xtra.co.nz...
Dear TekMaster

I think you are in the same boat as I am, keeping it simple - as long as it works then that is great.

I would prefer to use some of the other options listed by the other users,
but they seem a lot harder to implement and more importantly, less portable. If you type FTP in the windows run prompt and then from the prompt type
help, then you get all the commands that are available.

you can then type help close, for example, to find out about the close
command.

Thanks also for your

Nov 13 '05 #15
Dear Trevor,

I tried to use that > output.txt, but it does not work, do you have any
hints on that? I just seemed to crash.
Nov 13 '05 #16
WindAndWaves wrote:
Dear Trevor,

I tried to use that > output.txt, but it does not work, do you have any
hints on that? I just seemed to crash.


Maybe Access thinks "> output.txt" is part of the file name to execute?
I haven't tested this, perhaps you need to put the command into a batch
file then execute that.

--
Error reading sig - A)bort R)etry I)nfluence with large hammer
Nov 13 '05 #17

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

63 posts views Thread by Jerome | last post: by
13 posts views Thread by Simon Bailey | last post: by
64 posts views Thread by John | last post: by
17 posts views Thread by Mell via AccessMonster.com | last post: by
37 posts views Thread by jasmith | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.