How do I download and save a file from a website?

boblarson

Smeghead
Local time
Today, 11:47
Joined
Jan 12, 2001
Messages
32,059
I need to download several files from a website for processing, and I can sort of get it to work, but I am at a loss at the moment to figure out how to actually save the files.

I am currently using:
Code:
Application.FollowHyperlink "https://ebctest.cybersource.com/ebctest/TransactionExceptionDetailReport.csv"

and it works. It downloads the csv file, but automatically opens it in Excel instead of giving me the option to save it. I am creating this for multiple users, so I can't just change my file associations.

Anyone done this type of thing before?
 
I have put this into an example as it's too complex to Go Into Detail But you need to use the internet control Look at form 1 and it's code At The Min it downloads the login page as I havent got access so it saves the login page to csv LOL

Mick
 

Attachments

Hey Dreamweaver - I appreciate the effort, but I'm getting a database not recognized error, so you must have it saved in 2002, 2003, or 2007 version. I am on 2000 here at work, so I need a version that I can open from that. Would it trouble you too much to run a convert on this for me?

(as for my signature - I have XP and 2003 at home) :D
 
Works also on another system but that also has 2003 Sorry aint got 2000 maybe it wont work cause of the contol it uses?
 
Sorry, my bad. I am working remotely from a different location and didn't realize that the computer I'm working on actually doesn't have Access installed. :o
 
I'll check it out and try it out (probably tomorrow from my normal location). Thanks for the assistance, and sorry for the trouble I put you through for nothing (regarding the version).
 
This is the code you'll need but you'll need a ref to the msinternetcontrols plus insert an internet contol on the form match names Act.

Code:
Dim X As Integer
Dim B() As Byte
Dim sUrl As String

 
 'Open image
 B() = Inet1.OpenURL("https://www.ebctest.cybersource.com/ebctest/TransactionExceptionDetailReport.csv, icByteArray)
 
 'Open for a new file
 Open CurrentProject.Path & "\" & "TransactionExceptionDetailReport.csv" For Binary As #1
 
 Put #1, , B()
 Close #1
 Do
 DoEvents
  'Loop while still downloading
  Loop While Inet1.StillExecuting
 DoEvents
 
Last edited:
Tried using this and I can't get it to save properly. Using this method, I have two problems:

1. It doesn't prompt me for username/password like the website should (and does when I use the FollowHyperlink command).

2. The file doesn't save properly (probably because it isn't getting to the file as there is no login). "The file is not in a recognizable format"

I've also tried using the Internet Data Transfer Library on Dev Ashish's website
http://www.mvps.org/access/modules/mdl0037.htm
But with that one I can't get it to write out the CSV file either (it also doesn't prompt for login information).

So, to reiterate - I need to be able to:
1. Connect to a secure website (https)
2. put in the download string that the website has said will download the file (and it works if I do it with FollowHyperlink)
3. Be able to let the website prompt for username/password, or to supply it programmatically (which I'm not sure can be done).
4. Save the CSV file to a specified location

Thanks for any help that I can get.
 

Users who are viewing this thread

Back
Top Bottom