Language/Software:
The language is VBA. The application is Access 2003 (I also can use Excel) and Internet Explorer (on Windows XP/Seven).
The problem:
I’m developing a Access macro which opens and manipulates a intranet site of the enterprise where I work.
I can create new IE windows and fill data in the forms, but I need to be able of intercept and manipulate other IE windows, such as popups, which opens when I click on a link, when I choose an option of a select element or when the page is loaded.
Here’s some code I use to get an IE window from it’s title. It’s split into two functions because one of my users was having an extremely odd problem where an error was not being caught properly. You might (probably will) be able to move the body of the private function into the public function.
Additionally, you’ll need to set a reference to Microsoft Internet Controls (this is either shdocvw.dll or ieframe.dll, depending on your version of Windows) and I’d recommend setting a reference to Microsoft HTML Object Library to make it easier to traverse the DOM once you have your IE object.
Use the above code as follows:
You can find a window from almost any property of the window, or it’s document contents. If you’re struggling with this, please comment :).