PDA

View Full Version : Download File from Website From Excel



Whisky
05-09-2017, 03:31 AM
Hi,

I know some basic VBA for working with data within Excerl but very little HTML.

I can successfully open a website/link from website from Excel using chrome browser via:

Sub Chrome_Test()


'Loads Page
Dim WebUrl As String
'
WebUrl = "https://analytics.***xx.******.com/#/metrics?interval=r&datesel=d30&zoom=day&measure=units&type=line&app=971703112"
End sub

where is ***xx is part of the website name (the site also requires Username and password to access but I have got chrome to remember it)


On the page there is a download button that downloads a CSV file when clicking on it. I would like to hit the download button or do the eqv to download the CSV file on local machine using the VBA code in Excel.

I have used the "inspect" command to view the page. And the following HTML code seems to relate to the download button:

<div ng-click="getData()" class="icon cicon-download"></div>

Does anyone know how I would execute this line in VBA?

Alternatively as a fall back option I could use send keys. In this case does anyone know what combination of keys would mimic clicking left mouse button? Ctrl D does not work.

Many thanks

Whisky

offthelip
05-10-2017, 03:24 AM
Hi Whisky, welcome to the forum,
Unfortunately downloading information from websites is not that easy since every website is different.
Have a look at this thread which goes through a couple of ways of doing it but doesn't deal with the username and password problem, but it might get you started.
http://www.vbaexpress.com/forum/showthread.php?58935-Parsing-websites&highlight=

UrsulaSneat
07-27-2021, 07:26 AM
:hi: