Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VBA Internet Explorer Automation - How to Select "Open" When Downloading a File

This is my first question ever here on stackoverflow!

I've been searching for a solution to this problem for a while and haven't found any help. I may just be using the wrong keywords in my searches, but so far I've had no luck. Here's the question:

In VBA, how can I select the "Open" option from the file download dialog in Internet Explorer?

Just for extra clarification, I'm talking about the yellow-orange bar that pops up across the bottom of the screen in IE9 when a file is downloaded.

I'm doing some VBA automation to download hundreds of PDFs from the web using Internet Explorer, but there is an intermediate step where a .fdf file has to be opened before I get to the actual PDF. So I first need to select the "Open" option so that I can move on to the next step of the automation. Like I said earlier, I've done a lot of searching and had no luck so far.

I've tried using SendKeys in hopes that hitting Enter would work, and that was a last ditch effort that didn't work.

Thanks in advance for the help!

like image 877
Lane Sawyer Avatar asked May 01 '12 16:05

Lane Sawyer


People also ask

How do I get Internet Explorer to automatically download downloads?

File Download SettingsSelect Tools > Internet Options. Click the Security tab. Click Custom Level. About 1/3 of the way down the page, enable automatic prompting for file downloads and File download.

How do I open downloads on Internet Explorer?

To view files you've downloaded while using Internet Explorer, open Internet Explorer, select the Tools button, and then select View downloads. You'll be able to see what you've downloaded from the web, where these items are stored on your PC, and choose actions to take on your downloads.

How do I disable save or open dialog box on Internet Explorer while downloading CSV?

Open Internet Explorer > Tools > Internet Options > Security > Custom level > Download : Select Disable for 'Automatic prompting for file download'.


1 Answers

I sent the shortcut keys to the application. Here they are for IE11. Sorry I could not test in IE9. If you hold down Alt, it may show you the other key to the combo as IE11 does.

Note: the code will not run as you expect if IE is not the active window on your machine so it won't work while in debug mode.

  • Shortcut key:Alt+O
  • VBA: Application.SendKeys "%{O}"
like image 98
Tony L. Avatar answered Oct 17 '22 07:10

Tony L.