1

I need to authenticate to a website.

After successful authentication - a form is shown, where a few details are filled.

After submitting the form, the page gives an impression that something is loading:

report is being generated

After a non-fixed delay, a download pop up is shown:

download pop up in IE9+

Sadly, assuming if I try to download from URL, I cannot overcome the authentication part. The web browser client is authenticated, not the VBA client.

My simple question is:

  • How to detect, whether this download pop up has appeared or not in IE9+?

A few things I have tried:

I believe that after successfully detecting this pop up, I can download the file to local disk simply using SendKeys - correct me if needed.

Side question: how to download the file to local disk after detection is successful?

Community
  • 1
  • 1
Zameer Ansari
  • 28,977
  • 24
  • 140
  • 219
  • My first inclination is, after the download popup has appeared, to inspect the source of your download page, perhaps searching for the text "download" or "link", or search for the url the popup has provided. Similarly, try to search variables in the javascript console. I expect somewhere in there the URL you're looking for will exist. Then you ought to be able to reference the variable or HTML object that contains that URL using the DOM from VBA. This could be quite tedious, but I don't have (time, IE, current experience with this stuff) to provide a better suggestion, sorry! – mkingston Feb 16 '16 at 13:53
  • Just to be clear: I am aware the URL changes, I'm suggesting that each time the page is loaded, the relevant URL will be contained in (most likely) a javascript variable that you can get access to from VBA. – mkingston Feb 16 '16 at 13:54
  • @mkingston Sadly, assuming if I try to download from URL, I cannot overcome the authentication part. The web browser client is authenticated, not the VBA client. Btw, thanks for your feedback. – Zameer Ansari Feb 16 '16 at 15:00
  • 1
    It looks like it might be possible to disable the prompt and download automatically. I can't test this because I don't have IE9. If the script is just for your use this might be ok (you should probably read the disclaimer in the linked article). http://9to5it.com/internet-explorer-disable-do-you-want-to-open-or-save-this-file-prompt/. – mkingston Feb 16 '16 at 16:05
  • @mkingston I do not wish to disable the download pop up. Thanks anyways. – Zameer Ansari Feb 16 '16 at 16:10
  • 1
    Seems fair. In the vein of Siddarth's post, you could open IE, list all window handles/titles etc., then authenticate yourself in IE, wait until the download box has popped up and list window information again, seeing what's different. This may help you to obtain some identifying information for the download box. This code (that I do not endorse, nor have tested whatsoever) appears to do the needed: http://www.vbaexpress.com/kb/getarticle.php?kb_id=52 – mkingston Feb 16 '16 at 16:17

0 Answers0