
How to download csv file from any site - any more
Not worth the trouble of automating the process. Just open the csv file in Excel, save it as and Excel file and then import it into Access via the User Interface.
-- Hope this helps.
Doug Robbins - Word MVP,
dkr[atsymbol]mvps[dot]org
Posted via the Community Bridge
"OssieMac" wrote in message news:*** Email address is removed for privacy ***...
I would like sample of Access VBA code to automate the downloading of the Australian PostCode zip file and extract the csv file.I believe I can handle the code to import the csv file into an Access table in my project.
The Australia Post site is
http://auspost.com.au/products-and-services/download-postcode-data.html
There are 2 files at the site. The file required is
Download the current Postcode book extract file (pc-book_20100525.zip
<http://social.answers.microsoft.com/media/documents/pc-book_20100525.zip>;)
Because the download zip filename periodically changes to reflect the last update, it will be acceptable if the user needs to actually select the file at that point.
I have never done any automating of downloading files from the internet so I am hoping someone can help me with a code sample.
I have the required permission from Australia Post to use the downloaded data in my project.
-- Regards, OssieMac
Doug Robbins - Word MVP dkr[atsymbol]mvps[dot]org
Doug Robbins - MVP Office Apps & Services (Word)
dougrobbinsmvp@gmail.com
Screen shots by Snagit from www.techsmith.com
Was this reply helpful?
Sorry this didn't help.
Great! Thanks for your feedback.
How satisfied are you with this reply?
Thanks for your feedback, it helps us improve the site.
How satisfied are you with this reply?
Thanks for your feedback.
Regards, OssieMac
OssieMac
Was this reply helpful?
Sorry this didn't help.
Great! Thanks for your feedback.
How satisfied are you with this reply?
Thanks for your feedback, it helps us improve the site.
How satisfied are you with this reply?
Thanks for your feedback.
Actually, there is no need for the save as Excel part as you can Import a csv file directly using the Text File item in Import section of the External Data tab of the Ribbon.
Oops, I see that you are still using XP. That's a pity, because in Access 2007, you can save the steps as a Task which can be exported to Outlook from where you can forward it to other people.
-- Hope this helps.
Doug Robbins - Word MVP,
dkr[atsymbol]mvps[dot]org
Posted via the Community Bridge
"OssieMac" wrote in message news:*** Email address is removed for privacy ***...
Thanks for replying Doug. However, that is what I am doing now and I then have to distribute the update. I am hoping for something that the end users can do through an automated process without my assistance but if it is not possible then maybe what I need to do is to write some more instructions for the users and explain how to perform the operation for themselves.-- Regards, OssieMac
Doug Robbins - Word MVP dkr[atsymbol]mvps[dot]org
Doug Robbins - MVP Office Apps & Services (Word)
dougrobbinsmvp@gmail.com
Screen shots by Snagit from www.techsmith.com
Was this reply helpful?
Sorry this didn't help.
Great! Thanks for your feedback.
How satisfied are you with this reply?
Thanks for your feedback, it helps us improve the site.
How satisfied are you with this reply?
Thanks for your feedback.
Firstly I hope the originator found someone more useful than this Doug guy. Really! How about helpful replies only.....
I don't have a finished version to share, I will share when it is though. I can share my current process.
I have Excel downloading files at the moment....
Most of this will work in Access and then just a sub to import the file....
I am thinking thought that there is probably a way to do this in one process, download, read into VBA array and then import with SQL. So I'll go Google that and come back if I find it.
Hope the below helps if anyone finds it. Toodles!
Private Declare Function URLDownloadToFile Lib "urlmon" Alias _
"URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal _
szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
Sub DownloadFilefromWeb(URL As String, strSavePath As String)
ret = URLDownloadToFile(0, URL, strSavePath, 0, 0)
If ret = 0 Then
Else
MsgBox "Error"
End If
End Sub
Sub Downloads()
Dim URL As String
Dim SavePath As String
Dim InitialTime As Date
Do
InitialTime = Now()
URL = "https://connect.webfleet.tomtomwork.com/............."
SavePath = "C:\" & ActiveCell.Value & ".txt"
DownloadFilefromWeb URL, SavePath
'I can only make a request every so many seconds so I just chucked in a loop to ensure it didn't error out
Do
x = 1
Loop While InitialTime + (1 / 24 / 60 / 5) > Now()
ActiveCell.Offset(1, 0).Select
Loop While ActiveCell.Value <> ""
MsgBox "Done"
End Sub
4 people found this reply helpful
·Was this reply helpful?
Sorry this didn't help.
Great! Thanks for your feedback.
How satisfied are you with this reply?
Thanks for your feedback, it helps us improve the site.
How satisfied are you with this reply?
Thanks for your feedback.
0 thoughts to “How to download csv file from any site”