Microsoft Office 2000/Visual Basic Programmer's Guide   

Understanding the FrontPage Object Model

Microsoft FrontPage is designed to work with Web sites. A Web site can exist on a local intranet or on a server on the World Wide Web. There are several different metaphors you can use when envisioning a Web site. For example, you can think of a Web site as a collection of windows showing different parts of the Web site in an open instance of FrontPage. Or, you might think of a Web site as a collection of files on disk, organized in folders, all of which are organized under one main folder that contains the entire web. Finally, you could think of a Web site as the relationship between pages that exists as a result of the navigation structure between the pages.

When you have one or more Web sites open in FrontPage, the Webs collection contains a Web object representing each open Web site. Each Web object has a WebWindow object that represents the main application window containing the web. The WebWindow object looks like a separate instance of FrontPage; for example, each WebWindow object has its own FrontPage icon on the Windows taskbar. Each WebWindow object has a PageWindows collection that contains a PageWindow object for each open Web page. And each PageWindow object has a Document property that returns the DHTML document object for a Web page in the FrontPage web. For more information about the document object, see "Understanding the Page Object Model" later in this chapter.

When you first open FrontPage, you see a blank Web page open in Page view. You can use the Normal, HTML, and Preview tabs along the bottom of the page to edit the page in different ways or to preview it in your Web browser. The FrontPage menu bar and toolbars appear above the page, and the FrontPage Views bar appears along the left side of the page. At this point, FrontPage contains a single blank document only. There is no open Web site, and as a result, the Webs collection object's Count property returns zero. In addition, the WebWindows collection contains a single WebWindow object, and the PageWindows collection contains one PageWindow object that contains the blank page.

Each of these objects and collections has methods and properties you can use to work with the object. For example, the PageWindow object has a Document property you can use to work with the HTML elements contained in the Web page and an IsDirty property you can use to determine if the page has been changed. In addition, the PageWindow object has an ApplyTheme method you can use to apply a FrontPage theme to the page and Save and SaveAs methods you can use to save the page.

FrontPage-based webs exist on disk as a collection of files organized in folders. The base for the web is the root folder in the directory structure. For example, if you created a web called MyPersonalWeb on your hard disk, the root folder for the web could be C:\MyWebs\MyPersonalWeb. Under the MyPersonalWeb folder would be all the directories that make up your Web site. For example, when you use FrontPage to create a Web site based on the Personal Web template, FrontPage creates nine subfolders for the web that contain supporting files, such as images and style sheets.

The file structure of a web as it exists on disk is also available through the object model. Each folder in the web is represented by a WebFolder object. The RootFolder property returns the root WebFolder object in the web. The WebFolders collection contains a WebFolder object for each folder in the web. Each WebFolder object has, among others, a Folders property and a Files property. The Folders property returns a WebFolders collection for all the subfolders under a folder. The Files property returns a WebFiles collection that contains a WebFile object for each file in a folder.

The navigation structure of a Web site starts with a home page that can branch off to other pages in the Web site. In FrontPage, you can programmatically move through the navigation structure of a Web site by using NavigationNode objects. A NavigationNode object represents a node in the navigation structure of a Web site. The NavigationNodes collection contains all the NavigationNode objects in a Web site. You start navigation at the home page by using the HomeNavigationNode property, which returns the NavigationNode object for the Web site's home page. Each NavigationNode object has a Children property that returns the NavigationNodes collection representing all of the pages you can navigate to from a NavigationNode object. You use the Move method to move among NavigationNode objects in the NavigationNodes collection returned by the Children property. You use the Next and Prev properties to return the next or previous NavigationNode object.

Whether you use windows, files, or navigation nodes to move among objects in FrontPage will depend on what you are trying to accomplish.