By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,124 Members | 2,027 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,124 IT Pros & Developers. It's quick & easy.

how do you get a file off of a web server?

P: n/a
I would like to somehow get a file from a web address such as:
http://www.myserver.com/data/names.txt

and use in access.
I know I can use the Set http = CreateObject("microsoft.xmlhttp")
to read the file, but it will be pretty big like maybe over 1000 lines.
So how would I save this output to a text file, so I can then read it into a
table (it is a tab delimited file). I know how to do importing, but just
need help saving this big text to a text file.

Thanks again
Nov 13 '05 #1
Share this Question
Share on Google+
12 Replies


P: n/a
"Danny" <da********@hotmail.com> wrote in
news:U5********************@news4.srv.hcvlny.cv.ne t:
I would like to somehow get a file from a web address such as:
http://www.myserver.com/data/names.txt

and use in access.
I know I can use the Set http = CreateObject("microsoft.xmlhttp")
to read the file, but it will be pretty big like maybe over 1000 lines.
So how would I save this output to a text file, so I can then read it
into a table (it is a tab delimited file). I know how to do importing,
but just need help saving this big text to a text file.

Thanks again


Pretty well everyone uses ADO for almost everything now!

Public Sub GetAFile( _
ByVal URL As String, _
ByVal Destination As String, _
Optional ByVal UserName As String, _
Optional ByVal Password As String)
Dim r As ADODB.Record
Set r = New ADODB.Record
URL = "URL=" & URL
Destination = "file://" & Destination
With r
If Len(UserName) > 0 Then
.Open "", URL, , _
adOpenIfExists Or adCreateCollection, _
, UserName, Password
Else
.Open "", URL, , _
adOpenIfExists Or adCreateCollection
End If
.CopyRecord , Destination
.Close
End With
End Sub

Sub test()
GetAFile _
"http://ffdba.com/downloads/How_Many_WeekDays.dat", _
"c:/How_Many_WeekDays.dat"
End Sub

(you need the login for the site assuming it's not public.)

--
Lyle
(for e-mail refer to http://ffdba.com/)
Nov 13 '05 #2

P: n/a
Thanks Lyle,

I am not sure how to define the r variable.
I do not have the ADODB option I just have
DAO. I am using ms access 2002.

What can I do?

Thanks

"Lyle Fairfield" <Mi************@Invalid.Com> wrote in message
news:Xn*******************@130.133.1.4...
"Danny" <da********@hotmail.com> wrote in
news:U5********************@news4.srv.hcvlny.cv.ne t:
I would like to somehow get a file from a web address such as:
http://www.myserver.com/data/names.txt

and use in access.
I know I can use the Set http = CreateObject("microsoft.xmlhttp")
to read the file, but it will be pretty big like maybe over 1000 lines.
So how would I save this output to a text file, so I can then read it
into a table (it is a tab delimited file). I know how to do importing,
but just need help saving this big text to a text file.

Thanks again


Pretty well everyone uses ADO for almost everything now!

Public Sub GetAFile( _
ByVal URL As String, _
ByVal Destination As String, _
Optional ByVal UserName As String, _
Optional ByVal Password As String)
Dim r As ADODB.Record
Set r = New ADODB.Record
URL = "URL=" & URL
Destination = "file://" & Destination
With r
If Len(UserName) > 0 Then
.Open "", URL, , _
adOpenIfExists Or adCreateCollection, _
, UserName, Password
Else
.Open "", URL, , _
adOpenIfExists Or adCreateCollection
End If
.CopyRecord , Destination
.Close
End With
End Sub

Sub test()
GetAFile _
"http://ffdba.com/downloads/How_Many_WeekDays.dat", _
"c:/How_Many_WeekDays.dat"
End Sub

(you need the login for the site assuming it's not public.)

--
Lyle
(for e-mail refer to http://ffdba.com/)

Nov 13 '05 #3

P: n/a
I added the reference and it seems to work to a point, now I am getting a
runtime error on the
open statement. All urls and paths are correct.

What do you think?

Danny

"Lyle Fairfield" <Mi************@Invalid.Com> wrote in message
news:Xn*******************@130.133.1.4...
"Danny" <da********@hotmail.com> wrote in
news:U5********************@news4.srv.hcvlny.cv.ne t:
I would like to somehow get a file from a web address such as:
http://www.myserver.com/data/names.txt

and use in access.
I know I can use the Set http = CreateObject("microsoft.xmlhttp")
to read the file, but it will be pretty big like maybe over 1000 lines.
So how would I save this output to a text file, so I can then read it
into a table (it is a tab delimited file). I know how to do importing,
but just need help saving this big text to a text file.

Thanks again


Pretty well everyone uses ADO for almost everything now!

Public Sub GetAFile( _
ByVal URL As String, _
ByVal Destination As String, _
Optional ByVal UserName As String, _
Optional ByVal Password As String)
Dim r As ADODB.Record
Set r = New ADODB.Record
URL = "URL=" & URL
Destination = "file://" & Destination
With r
If Len(UserName) > 0 Then
.Open "", URL, , _
adOpenIfExists Or adCreateCollection, _
, UserName, Password
Else
.Open "", URL, , _
adOpenIfExists Or adCreateCollection
End If
.CopyRecord , Destination
.Close
End With
End Sub

Sub test()
GetAFile _
"http://ffdba.com/downloads/How_Many_WeekDays.dat", _
"c:/How_Many_WeekDays.dat"
End Sub

(you need the login for the site assuming it's not public.)

--
Lyle
(for e-mail refer to http://ffdba.com/)

Nov 13 '05 #4

P: n/a
"Danny" <da********@hotmail.com> wrote in
news:QH********************@news4.srv.hcvlny.cv.ne t:
I added the reference and it seems to work to a point, now I am getting
a runtime error on the
open statement. All urls and paths are correct.

What do you think?

Danny

"Lyle Fairfield" <Mi************@Invalid.Com> wrote in message
news:Xn*******************@130.133.1.4...
"Danny" <da********@hotmail.com> wrote in
news:U5********************@news4.srv.hcvlny.cv.ne t:
> I would like to somehow get a file from a web address such as:
> http://www.myserver.com/data/names.txt
>
> and use in access.
> I know I can use the Set http = CreateObject("microsoft.xmlhttp")
> to read the file, but it will be pretty big like maybe over 1000
> lines. So how would I save this output to a text file, so I can then
> read it into a table (it is a tab delimited file). I know how to do
> importing, but just need help saving this big text to a text file.
>
> Thanks again


Pretty well everyone uses ADO for almost everything now!

Public Sub GetAFile( _
ByVal URL As String, _
ByVal Destination As String, _
Optional ByVal UserName As String, _
Optional ByVal Password As String)
Dim r As ADODB.Record
Set r = New ADODB.Record
URL = "URL=" & URL
Destination = "file://" & Destination
With r
If Len(UserName) > 0 Then
.Open "", URL, , _
adOpenIfExists Or adCreateCollection, _
, UserName, Password
Else
.Open "", URL, , _
adOpenIfExists Or adCreateCollection
End If
.CopyRecord , Destination
.Close
End With
End Sub

Sub test()
GetAFile _
"http://ffdba.com/downloads/How_Many_WeekDays.dat", _
"c:/How_Many_WeekDays.dat"
End Sub

(you need the login for the site assuming it's not public.)

--
Lyle
(for e-mail refer to http://ffdba.com/)


A wild guess would be that your version of ADO is "pre-record-enabled". I
think you need hmmm ... 2.6 for this?

Of course, knowing what the run time error message, number is might be
helpful.

--
Lyle
(for e-mail refer to http://ffdba.com/)
Nov 13 '05 #5

P: n/a
On Fri, 04 Jun 2004 11:33:08 GMT, "Danny" <da********@hotmail.com>
wrote:

Why not use FTP? The "Microsoft Internet Transfer Control" makes that
pretty easy.

-Tom.
I would like to somehow get a file from a web address such as:
http://www.myserver.com/data/names.txt

and use in access.
I know I can use the Set http = CreateObject("microsoft.xmlhttp")
to read the file, but it will be pretty big like maybe over 1000 lines.
So how would I save this output to a text file, so I can then read it into a
table (it is a tab delimited file). I know how to do importing, but just
need help saving this big text to a text file.

Thanks again


Nov 13 '05 #6

P: n/a
This is the error
Run time error -1073446902 (c004800a).
"Lyle Fairfield" <Mi************@Invalid.Com> wrote in message
news:Xn*******************@130.133.1.4...
"Danny" <da********@hotmail.com> wrote in
news:QH********************@news4.srv.hcvlny.cv.ne t:
I added the reference and it seems to work to a point, now I am getting
a runtime error on the
open statement. All urls and paths are correct.

What do you think?

Danny

"Lyle Fairfield" <Mi************@Invalid.Com> wrote in message
news:Xn*******************@130.133.1.4...
"Danny" <da********@hotmail.com> wrote in
news:U5********************@news4.srv.hcvlny.cv.ne t:

> I would like to somehow get a file from a web address such as:
> http://www.myserver.com/data/names.txt
>
> and use in access.
> I know I can use the Set http = CreateObject("microsoft.xmlhttp")
> to read the file, but it will be pretty big like maybe over 1000
> lines. So how would I save this output to a text file, so I can then
> read it into a table (it is a tab delimited file). I know how to do
> importing, but just need help saving this big text to a text file.
>
> Thanks again

Pretty well everyone uses ADO for almost everything now!

Public Sub GetAFile( _
ByVal URL As String, _
ByVal Destination As String, _
Optional ByVal UserName As String, _
Optional ByVal Password As String)
Dim r As ADODB.Record
Set r = New ADODB.Record
URL = "URL=" & URL
Destination = "file://" & Destination
With r
If Len(UserName) > 0 Then
.Open "", URL, , _
adOpenIfExists Or adCreateCollection, _
, UserName, Password
Else
.Open "", URL, , _
adOpenIfExists Or adCreateCollection
End If
.CopyRecord , Destination
.Close
End With
End Sub

Sub test()
GetAFile _
"http://ffdba.com/downloads/How_Many_WeekDays.dat", _
"c:/How_Many_WeekDays.dat"
End Sub

(you need the login for the site assuming it's not public.)

--
Lyle
(for e-mail refer to http://ffdba.com/)


A wild guess would be that your version of ADO is "pre-record-enabled". I
think you need hmmm ... 2.6 for this?

Of course, knowing what the run time error message, number is might be
helpful.

--
Lyle
(for e-mail refer to http://ffdba.com/)

Nov 13 '05 #7

P: n/a
this is just a text file that sits on a server. Not necesarilly the ftp
server that I can ftp into.
when I put the url in the browser it lists the contents of the text fiel, I
just need to save it.
But the microsoft.xmlhttp method for some reason grabs only a small portion
of the entire file.

still working on the adodb method.
Thanks

"Tom van Stiphout" <to*****@no.spam.cox.net> wrote in message
news:rm********************************@4ax.com...
On Fri, 04 Jun 2004 11:33:08 GMT, "Danny" <da********@hotmail.com>
wrote:

Why not use FTP? The "Microsoft Internet Transfer Control" makes that
pretty easy.

-Tom.
I would like to somehow get a file from a web address such as:
http://www.myserver.com/data/names.txt

and use in access.
I know I can use the Set http = CreateObject("microsoft.xmlhttp")
to read the file, but it will be pretty big like maybe over 1000 lines.
So how would I save this output to a text file, so I can then read it into atable (it is a tab delimited file). I know how to do importing, but just
need help saving this big text to a text file.

Thanks again

Nov 13 '05 #8

P: n/a
Bri
Danny,

I use the Inet Activex control. For more info on the control check out:
http://support.microsoft.com/default...b;en-us;167268

The control came with the Developers version or with VB6, I'm not sure
if there are other sources. There is a sample DB in the above link that
will install the control (to be used by that DB), but I don't think that
you would then be able to add the control to your own form without the
one of the above licenses.

So if you can get the control:

Insert the control on your form and then in code (I put it on a command
button) I read the file on the website to a local file:
=======
Dim intFile as Integer
intFile = FreeFile()
strURL = "http://www.website.com/myfile.csv"
Open "c:\myfolder\myfile.csv" For Output As #intFile
Print #intFile, Inet.OpenURL(strURL)
Close #intFile
=======

You can now add code to import the file, etc.

HTH

Bri

Danny wrote:
I would like to somehow get a file from a web address such as:
http://www.myserver.com/data/names.txt

and use in access.
I know I can use the Set http = CreateObject("microsoft.xmlhttp")
to read the file, but it will be pretty big like maybe over 1000 lines.
So how would I save this output to a text file, so I can then read it into a
table (it is a tab delimited file). I know how to do importing, but just
need help saving this big text to a text file.

Thanks again

Nov 13 '05 #9

P: n/a
Thanks so much, I will investigate this.
In the meantime I found this, and this seems to work fine.
http://www.mvps.org/access/modules/mdl0037.htm

Thanks

"Bri" <no*@here.com> wrote in message
news:Tk1wc.632457$Pk3.60487@pd7tw1no...
Danny,

I use the Inet Activex control. For more info on the control check out:
http://support.microsoft.com/default...b;en-us;167268

The control came with the Developers version or with VB6, I'm not sure
if there are other sources. There is a sample DB in the above link that
will install the control (to be used by that DB), but I don't think that
you would then be able to add the control to your own form without the
one of the above licenses.

So if you can get the control:

Insert the control on your form and then in code (I put it on a command
button) I read the file on the website to a local file:
=======
Dim intFile as Integer
intFile = FreeFile()
strURL = "http://www.website.com/myfile.csv"
Open "c:\myfolder\myfile.csv" For Output As #intFile
Print #intFile, Inet.OpenURL(strURL)
Close #intFile
=======

You can now add code to import the file, etc.

HTH

Bri

Danny wrote:
I would like to somehow get a file from a web address such as:
http://www.myserver.com/data/names.txt

and use in access.
I know I can use the Set http = CreateObject("microsoft.xmlhttp")
to read the file, but it will be pretty big like maybe over 1000 lines.
So how would I save this output to a text file, so I can then read it into a table (it is a tab delimited file). I know how to do importing, but just need help saving this big text to a text file.

Thanks again


Nov 13 '05 #10

P: n/a
This is just what I was going to recommend. I have used it good
results. Also, no activex distribution issues.

- Jim

On Sat, 05 Jun 2004 00:27:14 GMT, "Danny" <da********@hotmail.com>
wrote:
Thanks so much, I will investigate this.
In the meantime I found this, and this seems to work fine.
http://www.mvps.org/access/modules/mdl0037.htm

Thanks

"Bri" <no*@here.com> wrote in message
news:Tk1wc.632457$Pk3.60487@pd7tw1no...
Danny,

I use the Inet Activex control. For more info on the control check out:
http://support.microsoft.com/default...b;en-us;167268

The control came with the Developers version or with VB6, I'm not sure
if there are other sources. There is a sample DB in the above link that
will install the control (to be used by that DB), but I don't think that
you would then be able to add the control to your own form without the
one of the above licenses.

So if you can get the control:

Insert the control on your form and then in code (I put it on a command
button) I read the file on the website to a local file:
=======
Dim intFile as Integer
intFile = FreeFile()
strURL = "http://www.website.com/myfile.csv"
Open "c:\myfolder\myfile.csv" For Output As #intFile
Print #intFile, Inet.OpenURL(strURL)
Close #intFile
=======

You can now add code to import the file, etc.

HTH

Bri

Danny wrote:
> I would like to somehow get a file from a web address such as:
> http://www.myserver.com/data/names.txt
>
> and use in access.
> I know I can use the Set http = CreateObject("microsoft.xmlhttp")
> to read the file, but it will be pretty big like maybe over 1000 lines.
> So how would I save this output to a text file, so I can then read itinto a > table (it is a tab delimited file). I know how to do importing, butjust > need help saving this big text to a text file.
>
> Thanks again
>
>




Nov 13 '05 #11

P: n/a

Hi Danny,
I'm alos getting the same runtime error
(-1073446902). If you resolved it. Please let me know. Meanwhile I try
from myside.


*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #12

P: n/a
Hi
I still get that error and I have no idea why.

I gave up on that method for now and use this method. It works fine.
Thanks so much, I will investigate this.
In the meantime I found this, and this seems to work fine.
http://www.mvps.org/access/modules/mdl0037.htm
"Prabhakar Natarajan" <pr*********@objectorb.com> wrote in message
news:40**********************@news.newsgroups.ws.. .

Hi Danny,
I'm alos getting the same runtime error
(-1073446902). If you resolved it. Please let me know. Meanwhile I try
from myside.


*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 13 '05 #13

This discussion thread is closed

Replies have been disabled for this discussion.