Download File?

jimbrooking

Registered User.
Local time
Today, 03:56
Joined
Apr 28, 2001
Messages
210
Does anyone have a code snippet or a reference I could peruse to learn how to automatically download a file from a web site?

We'd like to provide a list of documents (MS Word) on our web site for people to download if they need a sample form, document or whatever. We don't want to package these with the app, because they may change.

I'd like to give the user a button to click that will show a std. Windoze Open dialog, letting him/her pick where the file will be stored, and when the Open button is clicked, go to our web site, download the file, and store it in the designated location. (I don't mind if the download happens before the Open dialog opens.)

Been beating my head on this for a while and will appreciate any help from y'all.

Thanks,
Jim
 
use hyperlinks inside your DB. On whatever form or interface you are using, just add a link to the document file. Then, if you swap it out on the web end, clicking on the link jumps to the most recent copy.

look at hyperlinks in Access help, they show you exactly how to set one up...
 
Jatfill-

I know about hyperlinks. The problem with them is when you click on them a browser window opens. Then the user must figure out how to Save As... (in IE - it's different in NS) the document on the C-drive. I want to avoid the browser and fooling around with a FIle menu and do someting like a programmed HTTP transfer. FTP would be OK, too. (My client base has been described as middle-aged technical illiterates for whom booting the computer represents a moderate challenge.)

Looking at the MS Internet Transfer Control but have not seen an example I can make work yet.

Thanks,
Jim
 
Resurrecting This ...

This is an old thread I dug up because I have the same need and this thread appears to have been abandoned without solution two years ago.

Is there a way to download a file from a web site to a specific folder on C: without the download dialogue appearing?

Scott
 
Part of the download dialog is to allow the user the option as to where to save the file to (on the users PC) and also the file name that they want to save it as.

Could use the FileCopy statement if you are using VBA to copy the file from the internet to their PC? Assuming that they are connected to the internet.

HTH
 
From Another Thread ...

I was able to piece this together ...

*******************************
Private Sub DownloadOIG_Click()
On Error GoTo Err_DownloadOIG_Click
CopyFile "http://oig.hhs.gov/fraud/exclusions/downloadables/updatedleie.EXE", "C:\NHDB\OIG.exe"

Exit_DownloadOIG_Click:
Exit Sub

Err_DownloadOIG_Click:
MsgBox Err.Description
Resume Exit_DownloadOIG_Click

End Sub
*******************************
Sub CopyFile(FileNameAndPath As String, FileNameAndDestination As String)

Dim FSO As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
FSO.CopyFile FileNameAndPath, FileNameAndDestination, True

End Sub
*******************************

But when I run this, I get "Bad file name or number." I'm not sure what to make of that error message. Am I on the right track here?

Basically, what I want to do is provide a button which will go to a web site, download an exe file, then (and I haven't coded this yet) run the exe which will produce a text file, then TransferText the text file into an Access table -- all in one shot.

Scott
 
Whoa!

Jim, that stuff flew right over my head! LOL! I'm not sure about what those links should tell me, but I can't seem to relate their content to what I'm trying to do in Access VBA. They don't look like Access VBA to me but maybe I'm missing something.

Scott
 
Scott,

Sorry - lost my head there. I had recently solved the opposite problem - uploading a file into a database using an ASP page. And as you correctly point out, that's not what you're trying to do. :rolleyes:

Actually I was eventually able to get the MS Internet Transfer Control to work, in the sense that it copied a file from a web site to the user's hard drive. The site

http://www.vbip.com/itc/default.asp

may be helpful.

Jim
 
Jim -- Thanks a bunch! Awesome article! Now, before I jump head first into this thing, I noticed that this methodology is Active X oriented to pure Visual Basic code. Does its functionality apply identically to Access VBA code?

Scott
 
Scott,

I'm not sure I understand your question, but I will say when I had this thing going it was in a VBA environment, i.e., I was not using a Visual Basic separate from what comes with the Access 2K Developer Edition.

Good luck!
Jim
 
Jim -- Excellent -- that's what I needed to know -- thanks again for pointing me in the right direction!

Scott
 
Followup

Jim -- You might have known this followup question was coming. I don't have the Access Developer Edition here, just regular old Access 2000. Is it pretty much impossible to do this without the Developer Edition?

Scott
 
Solution for this

I've struggled with this issue myself for a few months. I tried Jim's links, but I didn't find them of use, because I really don't know VBA well enough. I did find, however, a Visual Basic project that was helpful (I could understand the code).

I downloaded it...And then, implemented a modified version into an Access database. The result of my efforts is attached. The zip file contains a database that will download any URL in the 'field1' field of the 'url' table, and save it to the 'saveloc' field of the 'url' table.

It's easy to use...Just open it up and double-click on "form1" - The code is in the on-open event. ...Imagine the power with some creative linking. You'll get an error message when all the files have been downloaded. (If you want to edit that out and post it, feel free....)

I welcome improvements and suggestions. I admit that I don't know a lot when it comes to Access or VB, so please be patient with me.

In the hopes that this will be helpful to someone else,

Andrew
 

Attachments

Leave it to me to ask a question about my own, posted advice.

Is there any reason why the database I posted above will refrain from downloading a url more than once? I think this is more of a Windows thing, but you all would know the issue either way.

The DB downloads the file, but if I make changes to the site they aren't reflected when I run the DB again. It still has the old version.

I've attempted to clear the temp internet files, and the history. The problem still exists.

Ideas?

Andrew
 
For future reference, I may have found a fix.

It seems that clearning Firefox history and cache is not the same as clearing the IE counterparts... I assumed the info was stored in the same directory.

This database appears to use IE protocalls when it seeks a URL and downloads it. That would explain why the data was stored in IE temporary internet files. The solution would appear simple: Cut off IE's storage of temporary internet files... I think the lowest you can set it is 1MB, but you can then have IE check for updates automatically.

Andrew
 

Users who are viewing this thread

Back
Top Bottom