Add Method

Microsoft FrontPage Visual Basic

Adds a new ListField object to the ListFields collection.

expression.Add(Name, Description, FieldType, Required, DefaultValue)

expression    Required. An expression that returns one of the above objects.

Name   Required. A String that represents the name of the field.

Description   Optional. A String that represents a description of the field.

DefaultValue   Optional. A Variant that defines the default value.

FieldType   Optional. An FpFieldType constant that represents the type of the new field.

FpFieldType can be one of these FpFieldType constants.
fpFieldAttachments
fpFieldChoice
fpFieldComputed
fpFieldCounter
fpFieldCurrency
fpFieldDateTime
fpFieldFile
fpFieldInteger
fpFieldLookup
fpFieldMultiLine
fpFieldNumber
fpFieldRatingScale
fpFieldSingleLine default
fpFieldTrueFalse
fpFieldURL

Required   Optional. A Boolean that determines if this is a required field. True if the field is required.

ShowAdd method as it applies to the Lists object.

Adds a new List object to the Lists collection.

expression.Add(Name, ParentFolder, ListType, Description)

expression    Required. An expression that returns a Lists object.

Name   Required. A String that represents the name of the new list.

ParentFolder   Optional. A String that represents the parent folder associated with the List.

ListType   Optional. An FpListType constant that represents the type of list.

FpListType can be one of these FpListType constants.
fpListTypeBasicList default
fpListTypeDiscussion
fpListTypeDocumentLibrary
fpListTypeSurvey

Description   Optional. A String that represents a description of the List object.

ShowAdd method as it applies to the NavigationNodes object.

Adds a new file to the list of available items in the NavigationNodes collection. Use this method to add a new file to the navigation structure. For more information on using navigation nodes, see the RootNavigationNode property for the Web object, or the Children property for the NavigationNode object.

expression.Add(Url, NodeLabel, ModificationType, LeftSibling)

expression    Required. An expression that returns a NavigationNodes collection.

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

NodeLabel   Required String. A string of text used to identify the NavigationNode object when viewing the navigation structure in Navigation view. The NodeLabel argument is used only as an aid to identification.

ModificationType   Required FpStructModType. The node modification type.

FpStructModType can be one of these FpStructModType constants.
fpStructBaseOnSibling Use this setting if you want to add a new node to the right of the node designated in the left sibling argument.
fpStructLeftmostChild The leftmost node in the current navigation structure.
fpStructRightmostChild The rightmost node in the current navigation structure.

LeftSibling   Optional Variant. An index into the NavigationNodes collection. It can be either a string that represents a URL, or a number that represents a node in the collection.

Remarks

Adding a new file onto the Web server (using the WebFiles.Add method) doesn't imply that you are automatically introducing the file into the navigation structure. A NavigationNode object must be created separately for the file. To create a new NavigationNode object, use the Add method for the NavigationNodes collection.

Note  When a template is used to create a new Web, navigation nodes are automatically created for the files that have been added to the Web by the template.

ShowAdd method as it applies to the PageWindows object.

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

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

expression.Add(FileUrl)

expression    Required. An expression that returns a PageWindows collection object.

FileUrl   Optional 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, Edit or Open method. When you want to open, edit, 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  It doesn't matter where the files exist; they could reside on a hard disk, server, or a FrontPage 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 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.

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 will fail. To add a new page, you must follow the procedure described earlier in this section.

ShowAdd method as it applies to the Properties object.

Adds a new property to the list of available items in the Properties collection.

expression.Add(PropertyKey, PropertyValue)

expression    Required. An expression that returns the Properties collection.

PropertyKey   Required String. A string that contains the name of the property that you want to add. For more information, see the table of properties in the Properties collection topic.

PropertyValue   Required Variant. The value of the property.

Remarks

You can programmatically add and remove categories and approval ratings for the Properties collection.

ShowAdd method as it applies to the WebFiles object.

Adds a new WebFile object to the list of available items in the WebFiles collection. A WebFile object is not restrictive and can be any type of file; it is not restricted to an HTML file type— it could be an image file, a movie, or an executable file.

Note  Use this method to add a new file to a FrontPage-based Web.

expression.Add(FileUrl, ForceOverwrite)

expression    Required. An expression that returns a WebFiles collection.

FileUrl   Required String. A string that contains the URL for the file such as "Inventory.htm". This can be any absolute URL for a file, such as http://web server/file    or file://file system/file for disk-based Webs.

ForceOverwrite   Optional Boolean.

Remarks

Accessing a single WebFile object through the WebFiles collection provides reference to a WebFile object that doesn't have access to the Page object model until the Web file is opened. Once the file is open, the PageWindow object associated with the file provides access to the Page object model that is compatible with Microsoft Internet Explorer 4.0 and later. For further information on using the Page object model in your Web pages, see Exploring the Object Model in FrontPage.

ShowAdd method as it applies to the WebFolders object.

Adds a new WebFolder object to the list of available items in the WebFolders collection.

expression.Add(FolderUrl)

expression    Required. An expression that returns a WebFolders collection.

FolderUrl   Required String. A string that contains the URL for the folder, such as the Images folder in C:\My Webs. This can be any absolute URL for a folder, such as http://web server/folder    or file://file system/folder for disk-based webs.

ShowAdd method as it applies to the WebPackage object.

Returns a Boolean that represents whether the specified file was successfully added to the Web package.

expression.Add(Url, flags)

expression    Required. An expression that returns a WebPackage object.

Url   Required String. The path and file name of the file to be added.

flags   Optional FpDependencyFlags. Specifies how to handle dependencies for the specified file. Dependencies are included only if they exist within the current Web site.

FpDependencyFlags can be a combination of one or more of the following FpDependencyFlags constants.

fpDepsDefaultIncludes all images, link bars, hyperlinks, lists, shared borders, and themes.
fpDepsImagesIncludes all images.
fpDepsLinkbarsIncludes all link bars.
fpDepsLinksIncludes all pages to which there are hyperlinks.
fpDepsListsIncludes lists that may be needed in order for the page to render correctly.
fpDepsNoneIncludes no dependencies.
fpDepsRecurseIncludes all files that are in a specified folder.
fpDepsSharedBordersIncludes all shared borders.
fpDepsThemesIncludes all themes.

Remarks

Use the CreatePackage method to create a new Web package. Then use the Add method to add pages and their specified dependencies to the Web package. You can create Web packages from files in Web sites based on Microsoft Windows SharePoint Services and in disk-based Web sites.

ShowAdd method as it applies to the Webs object.

Adds a new Web to the list of available items in the Webs collection.

Security    Avoid using hard-coded passwords in your applications. If a password is required in a procedure, request the password from the user, store it in a variable, and then use the variable in your code. For recommended best practices on how to do this, see Security Notes for Microsoft Office Solution Developers.

expression.Add(WebUrl, UserName, Password, WebOpenFlags)

expression    Required. An expression that returns a Webs collection object.

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

UserName   Optional String. The user's logon name for the Web server.

Password   Optional String. The user's password for the Web server.

WebOpenFlags   Optional. An FpWebOpenFlags constant that represents the behavior of the new Web.

FpWebOpenFlags can be one of these FpWebOpenFlags constants.
fpOpenInWindow default
fpOpenNoWindow

ShowAdd method as it applies to the WebWindows object.

Adds a new WebWindowEx object to the WebWindows collection.

expression.Add(ViewModeEx)

expression    Required. An expression that returns a WebWindows collection.

ViewModeEx   Required. An FpWebViewModeEx enumerated constant that represents the information displayed in the new window.

FpWebViewModeEx can be one of these FpWebViewModeEx constants.
fpWebViewExAccessibility
fpWebViewExAllFiles
fpWebViewExAssignedTo
fpWebViewExBrokenLinks
fpWebViewExBrowserTypes
fpWebViewExCategories
fpWebViewExCheckoutStatus
fpWebViewExComponentErrors
fpWebViewExCSSLinks
fpWebViewExDailyPageHits
fpWebViewExDailySummary
fpWebViewExFolders
fpWebViewExLinks
fpWebViewExMasterPages
fpWebViewExMonthlyPageHits
fpWebViewExMonthlySummary
fpWebViewExNavigation
fpWebViewExOlderFiles
fpWebViewExOsTypes
fpWebViewExPage
fpWebViewExPublishStatus
fpWebViewExRecentlyAddedFiles
fpWebViewExRecentlyChangedFiles
fpWebViewExReferringDomains
fpWebViewExReferringURLs
fpWebViewExRemoteSite
fpWebViewExReviewStatus
fpWebViewExSearchStrings
fpWebViewExSharedBorders
fpWebViewExSiteSummary
fpWebViewExSlowPages
fpWebViewExThemes
fpWebViewExTodo
fpWebViewExUnlinkedFiles
fpWebViewExUsageSummary
fpWebViewExVisitingUsers
fpWebViewExWeeklyPageHits
fpWebViewExWeeklySummary

Example

ShowAs it applies to the NavigationNodes object.

This example adds a new node called footnote.htm to the list of items in the NavigationNodes collection.

Note  To run this example, you must have a Web site called "C:\My Documents\My Webs\Coho Winery" that contains a file called footnote.htm. Or, you may substitute an alternative Web site URL or file name.

Private Sub AddNewNavNode()
Dim myHome As NavigationNode
Dim myNewNode As NavigationNode
Dim myFileUrl As String

myFileUrl = "C:\My Documents\My Webs\Coho Winery\footnote.htm"
Set myHome = ActiveWeb.HomeNavigationNode
Set myNewNode = _
    myHome.Children.Add (myFileUrl, _
    "Footnote", fpStructLeftmostChild)
ActiveWeb.ApplyNavigationStructure
End Sub
						

ShowAs it applies to the PageWindows object.

This example adds the Inventory page for Coho Winery to the list of items in the PageWindows collection. When you add a page using the FileUrl argument, the page that you want to add must exist as a file— you cannot create a new page using this argument. To create an unsaved new page, see the description in the Add method.

Note  To run this example, you must have a Web site called "C:\My Documents\My Webs\Coho Winery" that contains a file called Inventory.htm. Or, you may substitute an alternative Web site URL or file name.

Private Sub AddPage()
Dim myPageWindows As PageWindows
Dim myPage As String

Set myPageWindows = ActiveWeb.ActiveWebWindow.PageWindows
myPage = "C:\My Documents\My Webs\Coho Winery\Inventory.htm"

myPageWindows.Add (myPage)
End Sub
						

ShowAs it applies to the Properties object.

This example adds a new file to the list of items in the Properties collection.

Note  To run this example, you must have a Web site called "C:\My Documents\My Webs\Coho Winery\Zinfandel.htm" that contains a file called footnote.htm. Or, you may substitute an alternative Web site URL or file name.

Private Sub CopyrightAdd()
Dim myWeb As WebEx
Dim myCopyright As String
Dim myCopyrightProperty As Variant

myCopyright = "Copyright 1999 by Coho Winery"
Set myWeb = Webs.Open("C:\My Webs\Coho Winery")
myWeb.Activate

ActiveWeb.Properties.Add "Copyright", myCopyright
ActiveWeb.RootFolder.Files("Zinfandel.htm").Open
ActiveDocument.body.insertAdjacentText "BeforeEnd", _
    ActiveWeb.Properties("Copyright")
ActivePageWindow.Save
ActiveWeb.Close
End Sub
						

ShowAs it applies to the Webs object.

This example adds a new item to the list of files in the Webs collection.

Webs.Add ("C:\My Documents\My Webs\Coho Winery")
						

ShowAs it applies to the WebFiles object.

This example adds a new WebFile object to the list of items in the Files collection.

ActiveWeb.RootFolder.Files.Add ("C:\New Web Files\Sales Statistics.htm")
						

ShowAs it applies to the WebFolders object.

This example adds a folder to the list of items in the WebFolders collection.

ActiveWeb.RootFolder.Folders.Add ("Distribution Centers")
						

ShowAs it applies to the WebPackage object

The following example creates a new Web package and adds the page "test.htm" to the package, including all dependencies for the page, and then saves the new Web package.

Dim objWeb As WebEx
Dim objPackage As WebPackage

Set objWeb = ActiveWeb
Set objPackage = objWeb.CreatePackage("New Web Package")

With objPackage
    .Author = "John Smith"
    .Company = "Fourth Coffee"
    .Subject = "This is a new Web package for Fourth Coffee."
    .Add objWeb.Url & "/test.htm", fpDepsDefault
    .Save "c:\NewWebPackage.fwp", True
End With