VBA / Download file from the web.

I have a Microsoft Access application running on an RDP server that is heavily locked down.  I need to give users the ability to download files from a link (such as Dropbox), which can then be processed by the application (Excel for importing, PDF for email attachments etc).  

I have created a form that allows users to enter the link and found a couple of code snippets that in theory handle the download (using URLDownloadToFile and the Microsoft.XMLHTTP object).  However, whilst it does generate a file - it's an HTML file (not the PDF test file I was hoping for)

Does anyone know of a reliable way of downloading the actual file?
Andy BrownDeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gustav BrockCIOCommented:
Yes, my DownloadFile function here:

Show pictures directly from URLs in Access forms and reports

but when you tell that it downloads the html file (the page), it tells me that you don't use the URL for the file itself (the pdf).
So, how is your URL looking, please?
0
Andy BrownDeveloperAuthor Commented:
Hi Gustav - it's been a while - hope you are well.

Here is a link to the test file.  I ultimately want to download this file to D:\fenix3_OM_EN.pdf

https://www.dropbox.com/s/3t70keflzd9nsce/fenix3_OM_EN.pdf?dl=0
0
Gustav BrockCIOCommented:
It seems like they fool you.
That URL only displays the file. The download is initiated by the button-click calling a function.


It can be done using .Net, and Dropbox provide full documentation, not only for VB(A):

https://www.dropbox.com/developers

You probably will need the webbrowser component to carry this out.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Andy BrownDeveloperAuthor Commented:
Thanks Gustav - I went onto the Developers area, looked at the HTTP settings and discovered that if you replace =0 at the end with =1, then it downloads it (rather than open it).

https://www.dropbox.com/s/3t70keflzd9nsce/fenix3_OM_EN.pdf?dl=1
0
Gustav BrockCIOCommented:
Hmm. That was my first thought: dl = download, and 0 = False, thus try 1 for True.
But it didn't work for me. Or so it seemed.

I tried again, and right, it works.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
HTML

From novice to tech pro — start learning today.