Microsoft Internet Explorer is a general-purpose browser application that displays HTML documents located on the Internet, corporate intranet, or your local hard disk. Although Internet Explorer doesn't have its own Visual Basic Editor, you can use its objects through Automation by manipulating a simple collection of properties, methods, and events.
The Internet Explorer object library typically resides on all systems that maintain an installed copy of Internet Explorer. (In other words, if Internet Explorer is properly recorded in the system registry, an object library will also be present.) Because Internet Explorer is included with Office 2000, you have everything you need to issue Internet Explorer commands from within an Office macro. By writing just a few lines of code, you can quickly start Internet Explorer and display any Web page on the Internet that you have access to.
Unfortunately, Netscape Navigator has a different object model and therefore can't be controlled with the Automation commands shown here.
Follow these steps to create the WebPage macro, a Word utility that uses Internet Explorer to open the Microsoft Corporation home page in Internet Explorer. (You can substitute your own Internet address for the Microsoft address if you want.)
ON THE WEB
The WebPage macro is located in the Chap62 document on the Running Office 2000 Reader's Corner page.
Set Explorer = New SHDocVw.InternetExplorer Explorer.Visible = True Explorer.Navigate "http://www.microsoft.com"
This macro uses an object variable named Explorer to represent the InternetExplorer class in the SHDOCVW.DLL object library. The macro then starts and displays the Internet Explorer application in a window and uses the Navigate method to open the Microsoft Corporation Web page. This program code is all you need to open an HTML document in your browser.
Figure 41-3. Using the Internet Explorer object model, you can quickly open your favorite Web site from within a macro.
Congratulations! You have learned how to use several Office applications remotely in an Office macro. Take this accomplishment as your starting point, and continue learning about the object models for each Office application using the Object Browser tool. The wide world of macro programming awaits you!