We receive emails with links to documents, or more precisely, links to webpages that contain buttons we click to download documents. I want to automate this under Office 2016, IE 11, and Windows 7 Enterprise. I've gotten this far.
In VBA, I set references to Microsoft HTML Object and Internet Controls libraries. I load the page, locate the button control on the page, and issue the button's click method. Then I get the prompt you see above. I want to save as... that is, each downloaded file will go in a particular directory. How would you do that?
EDIT: The URL to the file is not contained in the web page's source. The code for the Download button is this:
<form action="/Home/NoCaptcha" method="post">
<input type="submit" class="btn btn-primary btn-lg" value="Download" style="margin-top: 40px;" />
</form>
The prompt is not part of the webpage, so I can't use HTML to find the button. I could use SendKeys (not ideal), but even then, I could only send Alt-S to save. Is there a way of virtually clicking on the down arrow to expose the Save As option? But if I do this, how do I enter the location of the file? Would I have to somehow control the actual Save As dialog box?
Assuming I can use SendKeys to send an Alt-S, just before doing that, I could change the registry key that holds the default download location. But this would involve writing to the registry hundreds of times per day. Are there consequences to this? Do I risk corrupting the registry?
EDIT: I suppose if IE automatically downloaded the file, that would solve my problem too Further research uncovers that the option to download without prompts was removed since IE 10.