Add Method (PageWindows Collection)

See Also         Example         Applies To

Adds a new PageWindow object to the list of available open items in the PageWindows collection.

Note   Opening a new or existing file object using the Add method for the PageWindow object also adds the PageWindow object that is associated with the opened file to the PageWindows collection.

Syntax

expression.Add(FileUrl As String)

expression   An expression that returns a PageWindows collection object.

FileUrl   Required String. A string that contains the path for the Web server where the page will be stored. This can be any absolute URL for a file, such as http://web server/file or file://file system/file for disk-based webs.

Remarks

You can use one of three methods when you want to open HTML pages in Microsoft FrontPage Page view—the Add method, the Edit method, or the Open method. When you want to open a file in Page view that exists either on a file server or on a file system on your hard drive, edit it, and then save it, use the Add method for the PageWindows object, as shown in the following statements.

Note   It doesn't matter where the files exist; they could reside on a hard drive, server, or a FrontPage-based web.

Dim myFile As String

myFile = "C:\Adventure Works HTML Files\Hiking.htm"
ActiveWeb.ActiveWebWindow.PageWindows.Add (myFile)

With this method, you haven't added the file to a FrontPage-based web—you've just opened it. If myFile is part of a web, and the web is currently not open, FrontPage will also open the web.

When you want to open and edit an HTML file that exists on a web, use the Edit method for the Files collection in the root folder, as shown in the following statement.

ActiveWeb.RootFolder.Files("Hiking.htm").Edit

You can also use the Open method as shown in the preceding statement, however, you should reserve the Open method for opening files that are not HTML files, such as Microsoft Word documents, image files, and so on.

You can also use the Add method to open a new unsaved PageWindow object. You can use either of the following statements to open an unsaved page window.

Set myUnsavedPageWindow = ActiveWebWindow.PageWindows.Add()
Set myUnsavedPageWindow = ActiveWebWindow.PageWindows.Add("")

Note   You can use the expression ActiveWebWindow.PageWindows.Add("C:\My Documents\My Webs\index.htm") as a valid expression as long as index.htm is a valid FrontPage-based file that resides in My Webs. However, if index.htm does not reside in My Webs, your code would fail. To add a new page, you must follow the procedure described earlier in this section.