Web File Download

Gettingbetter

Well-known Member
Joined
Oct 12, 2004
Messages
602
Hi Everyone.

I was looking for an answer to this all day Friday without any luck. So I thought I would ask on here to see if anyone knows how to do it.

There are a lot of people asking this question (when I google it) but no one has a solution, so it might not be possible.

I am linking to a webpage in VBA using the web browser control. I login with a username and password (all works fine), scrape a couple of tables off the page (all works fine) I then have to click a button to get a CSV file.

I have looped through the webpage and found the item I need to click the button the problem is that it comes up with the box, Do you want to open or save this file? with the options, Open, Save, Cancel.

What I would like is to programticaly choose a file location and save the CSV file there. So that the user does not need to do anything.

The problem is that I can not use the API call

Private Declare Function URLDownloadToFile _
Lib "urlmon.dll" Alias "URLDownloadToFileA" ( _
ByVal pCaller As Long, _
ByVal szURL As String, _
ByVal szFileName As String, _
ByVal lpfnCB As Long) As Long

Because the URL of the CSV is never given to me (its not in the source of the web page anywhere) and because of the nature of the web page I need to use the webBrowser control as there are alot of links (that change constantly) that I need to click to get to the download section.

I cant provide deatils of the webpage as its all secure, but the line line of code that clicks the button is
WebBrowser1.Document.forms(37).Item(10).Click

Has anyone any idea how to skip the 'Do you want to open or save this file?' box????? When you dont have the URL of the file???

Cheers
GB
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Application.DisplayAlerts = False

After a routine you must turn on alert messages:

Application.DisplayAlerts = True
 
Upvote 0

Forum statistics

Threads
1,215,652
Messages
6,126,033
Members
449,281
Latest member
redwine77

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top