Recently I've been developing with VBScript. It's not because I think of it as a cutting-edge technology I need to learn, but rather because at work I'm stuck with a locked-down XP computer without any other programming tools, no internet access and no administrator privileges. Let's just say that software development isn't part of my current job description (There's a back-story here, but that's a story for a different day).
The application we are using at work is browser-based, but the UI (am I supposed to call it Ux now?) is horrible. Since our group is apparently far too low on the totem-pole to get our suggestions implemented, I've been writing scripts to ease our pain. The next step in this endeavor is to automate Internet Explorer and that's where the plot thickens.
There are two related "objects" you can use to automate IE: the InternetExplorer Object and the WebBrowser control. They are both available through Shdocvw.dll and that's where the confusion begins. The InternetExplorer object is an automation interface to IE. The WebBrowser control is an ActiveX control that can be hosted within an application.
MSDN documents both of them in the documentation tree under WebBrowser Control here. This leads some people to believe that the following code creates a WebBrowser control but it doesn't:
Set objIE = CreateObject("InternetExplorer.Application")
It does, however, create an InternetExplorer object. This distinction is important for a two reasons. First, because the above code will open an instance of the standard IE application which doesn't happen you create a WebBrowser control. And secondly, because the events supported by each is different.
Adding to the confusion, events supported exclusively by the InternetExplorer object aren't supported in the way you might assume. For example, if you set the StatusBar to False in your code, it will hide the Status Bar in your Automated IE instance and will trigger an OnStatusBar event. On the other hand, if you then go to your automated IE window and select "Status Bar" from the "View" menu, it will make the Status Bar visible, but it will not trigger the OnStatusBar event.
No comments:
Post a Comment