>> > This seemed easy at first...
>> > I have a database which users can download from a web site in a zipped
[quoted text clipped - 41 lines]
> If I use IE it opens the file with that address OK.
> Bob
> >> > This seemed easy at first...
> >> > I have a database which users can download from a web site in a zipped
[quoted text clipped - 54 lines]
> If the file resides elsewhere, you need to bone up on relative paths. You're
> sure to turn up something on Google...
Hi Stuart,
well, as the file's on a remote web server it would need to be an absolute
reference. However, many hours further research reveals that Open can't be
used with ftp or http, but elsewhere on the forum in an old thread, Doug
Steele has once again come up with an answer. I've copied the reference
below:
[ See whether what I wrote about in my November, 2003 "Access Answers" column
for Pinnacle Publication's "Smart Access" has what you need.
You can download the column (and accompanying sample database) for free at
http://www.accessmvp.com/djsteele/SmartAccess.html ]
There's also info in there about extracting what you want from the html
which is returned. In my case I don't need that as I'm getting data from a
plain .txt file which consists of just text (actually, a number). As I'm the
one putting the file there, I can be sure of the format.
This is the code of Doug's I've tested in case anyone else is struggling
with this:
Function GetFromWebpage(URL As String) As String
On Error GoTo Err_GetFromWebpage
Dim objWeb As Object
Dim strXML As String
' Instantiate an instance of the web object
Set objWeb = CreateObject("Microsoft.XMLHTTP")
' Pass the URL to the web object, and send the request
objWeb.Open "GET", URL, False
objWeb.Send
' Look at the HTML string returned
strXML = objWeb.responseText
GetFromWebpage = strXML
Debug.Print GetFromWebpage
End_GetFromWebpage:
' Clean up after ourselves!
Set objWeb = Nothing
Exit Function
Err_GetFromWebpage:
' Just in case there's an error!
MsgBox Err.Description & " (" & Err.number & ")"
Resume End_GetFromWebpage
End Function
So using my example from earlier in this post:
GetFromWebpage "http://website.net/test.txt"
- returns my text (number) - I just need to sort out what I do with it now...
Bob
Stuart McCall - 25 Apr 2008 08:37 GMT
>> >> > This seemed easy at first...
>> >> > I have a database which users can download from a web site in a
[quoted text clipped - 118 lines]
>
> Bob
Yes that's the correct way to get the text. Sorry for leading you astray
(don't know what I was thinking). Incidentally, there's another method,
similar to Doug's that uses InternetReadFile from wininet.dll:
http://www.smccall.demon.co.uk/MiscApi.htm#Scrape
(purely out of interest, being as you have a solution)