Share via


PageWindows.Add Method

SharePoint Designer Developer Reference

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

Syntax

expression.Add(FileUrl)

expression   Required. A variable that represents a PageWindows collection.

Parameters

Name Required/Optional Data Type Description
FileUrl Optional String Specifies 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 Web sites.

Remarks

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

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

Note

The location of the files doesn't matter; they can reside on a hard disk, on a server, or within a Web site.

Visual Basic for Applications
Dim strFile As String
myFile = "C:\AdventureWorks\HTML\Hiking.htm"
ActiveWeb.ActiveWebWindow.PageWindows.Add (strFile)

With this method, you haven't added the file to a Web site in Office SharePoint Designer—you have simply opened it. If strFile is part of a Web site, and the Web site is currently not open, Office SharePoint Designer will also open the Web stie.

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

Visual Basic for Applications
ActiveWeb.RootFolder.Files("Hiking.htm").Edit

You can use the Open method in the same way. 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.

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

See Also