Alternative to sendkeys (in VBA) for a website dealing with angularjs

ryanblumenow

New Member
Joined
Jul 18, 2017
Messages
5
Hi there everyone,

I hope you can help me. Please excuse if I get any terminology wrong, as I only code in VBA and have no experience with other languages.

I am trying to download a file from www.loyverse.com, which is in AngularJS. The website requires a login, and after login to click on a certain area of the webpage to download a CSV, which is the file that I am trying to integrate into my workbook (I have already written code to do this part). The issue is downloading the file.

Because I don't know AngularJS at all, I am using SendKeys to login and click on things, but it is too volatile and at times virtually unusable.

Is there an alternative to SendKeys I can use? Or can someone help me with a Jscript to download this file?

It's really becoming quite a concern to me, the rest of my code works really nicely, but the SendKeys and AngularJS make this almost intolerable.

Would really appreciate any help.

Thank you!

Ryan
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Ryan

Have you checked the HTML behind the page?
 
Upvote 0
Hi Norie,

Yes we have, but we are not well versed in dealing with AngularJS (or HTML) and I have to admit it was a bit Greek to me.

We can identify the tags for the elements we need to click on, but can't work out what to do from there.
 
Upvote 0
If you can see the HTML then you probably don't need SendKeys.

I don't have time right now to look at the page but if you search this board for 'IE automation' or something similar you should find examples of working with web pages via VBA.
 
Upvote 0
There are 3 ways to download the file:

1. Send XMLhttp GET and/or POST requests to request the webpage and download the file. The VBA code must emulate the exact GET/POST requests which a browser sends when it downloads the file. These requests might include hidden input element names and values and session data/cookies from the request to GET the webpage containing the download link. Use Fiddler or the IE Developer tools (press F12 key) Console or Network tabs to see the requests which IE sends. Example code and explanations in these threads:

https://www.mrexcel.com/forum/excel...n-internet-explorer-web-site.html#post3404965
https://www.mrexcel.com/forum/excel...-applications-downloadfile-3.html#post4792264 (*)

2. Automate IE using the InternetExplorer object and HTML Object Library to click the link which causes the IE download file dialogue to appear and then use Windows API functions to automate the download windows. This method works in IE8+. See
https://www.mrexcel.com/forum/excel...ile-download-dialog-box-without-sendkeys.html
https://stackoverflow.com/questions...on-how-to-select-open-when-downloading-a-file.

3. A variation of option 2 for IE9+: automate IE using the InternetExplorer object and HTML Object Library to click the link which causes the IE download information bar to appear at the bottom of the browser window and then use the CUIAutomationClient object to automate the file download.
https://www.mrexcel.com/forum/excel...ual-basic-applications-website-accessing.html
https://www.mrexcel.com/forum/excel...ic-applications-downloadfile.html#post4781043 (*)

(*) - Posts from the same thread, showing two different techniques for downloading a file from the same website.

For options 2 and 3, there are several ways of clicking the download link:

a) For IE8, call the Click method on the link/button, or call fireEvent "click" on the link/button, whichever works.
b) For IE9, call the Click method on the link/button, or call dispatchEvent on the link/button, whichever works.
c) Sometimes, particularly with JQuery and similar client-side JavaScript libraries, I've found that neither fireEvent nor dispatchEvent have any effect, so I've written a VBA class which uses JScript to send mouse or key events to a HTML element and this seems to work better.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,070
Messages
6,128,615
Members
449,460
Latest member
jgharbawi

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