What's New for Developers in FrontPage

Microsoft FrontPage 2000 now includes a Microsoft Visual Basic for Applications object model to support new and improved features in the application. Many methods that you were familiar with in FrontPage 98 are still available but have been replaced by language elements that take advantage of the new object model. For more information on the new feature areas in FrontPage, refer to the section on New Feature Areas; for details on language elements, refer to the section entitled New Language Elements; or, for details on language elements that have been hidden, refer to the section Hidden Language Elements.

New Feature Areas

The following topics provide conceptual information about features that are new in FrontPage 2000.

Accessing the Object Model in FrontPage from Design-Time Controls

Accessing Framesets with Microsoft Visual Basic

Coding in a Windowless Environment

Creating Web Sites With Microsoft FrontPage 2000

Exploring Procedures

Exploring the Object Model in FrontPage

Managing Publishing with Meta Tags

Managing Source Control Projects

Modifying Pages Programmatically

Programming Dynamic Elements

Sharing Programming Projects

Understanding Absolute and Relative URL Addressing

Using Events to Control Actions

New Language Elements

Microsoft Visual Basic for Applications is new to FrontPage. You can automate FrontPage from your Microsoft Word or Microsoft Excel macro and use all of the commands you are familiar with and more. Now you have commands that help you manage Web sites, create FrontPage-based web pages, and communicate with Microsoft Office macros and applications as well as the familiar Visual Basic macro tools.

The new language elements in Visual Basic replace the FrontPage 98 language elements. However, the FrontPage 98 elements are included in FrontPage 2000 as hidden elements for purposes of backward compatibility, but are not recommended for use with Visual Basic in FrontPage 2000.

Hidden Language Elements

The Microsoft FrontPage 98 OLE Automation interfaces are now depreciated in favor of the new, richer object model. The old automation interfaces will continue to work. The one caveat is that if a user has mulitple windows open, any call that operates on a web will use the web contained in the top most FrontPage window.

Old style menu customization has been replaced with the Microsoft Office command bar customization.

Designer HTML has been replaced with a combination of Office AddIns and the richer object model.


Creating Web Sites With Microsoft FrontPage 2000

Creating Web Sites

Microsoft FrontPage 2000 makes FrontPage-based web creation as easy as creating a new folder on your hard drive. The key to successful web management in FrontPage is planning the structure and design of your webs. As many FrontPage 98 users know, FrontPage creates a unique environment for Web sites that provides greater flexibility for the Webmaster. With most Web servers, you have one Web site, but with FrontPage, you can create as many webs as you want, including nested webs. A FrontPage-based web comprises three layers—web structure, folder structure, and navigation structure. Click one of the links below to select a specific topic.

Understanding FrontPage Web Structure

Understanding FrontPage Folder Structure

Understanding Navigation Structure

Creating Web Sites Programatically

Creating a Web Site with the Add Method

Creating a Web Site with the MakeWeb Method

Understanding FronPage Web Structure

Any folder on your Web server can be a web with its own folder hierarchy that can include subwebs below the original web. When you install FrontPage, the program automatically provides a default name for your main web. On a disk-based system, the default name is C:\My Documents\My Webs for a Microsoft Windows operating system or C:\WINNT\Profiles\logon alias\Personal\My Webs for a Microsoft Windows NT operating system. You may want to name the individual subwebs for the various company names themselves, such as Adventure Works, American Society of Science, Encore Musical Instruments, Mightyflight Toys, or Rogue Cellars.

FrontPage provides a variety of web templates—corporate, discussion, customer support, and so on. These templates provide the foundation of the structure for each web. For example, Adventure Works may want you to establish a full-blown corporate presence for their Web site; while Encore Musical Instruments already has a web that you'll be importing, but wants you to add a customer support web, and so on. The web hierarchy for a disk-based web is shown in the following diagram.

Figure 0.1 Conceptualized view of a web structure.

The following figure shows the web structure in Folders view. The subwebs display a small globe within the folder icon.

Figure 0.2 Subwebs shown within the main web structure.

Understanding FrontPage Folder Structure

The folder structure in FrontPage behaves in the same manner as the folder structure in Windows Explorer However, to access these files from Windows Explorer, you have to export them to another location—either your hard drive or server. During the export process, the files are converted to HTML pages. In that sense, opening FrontPage is similar to opening a window to your webs. The folder hierarchy for a disk-based web is shown in the following diagram.

Figure 0.3 Conceptualized view of a folder structure.

The following figure shows the folder structure in Folders view.

Figure 0.4 Folders shown within a combined folder/web structure.

Note This figure displays the same information as the previous one because both folders and webs are displayed in the same view, but you can see from the web and folder diagrams that they each have their own structure. A web or subweb is a folder. However, a folder that is also a web contains meta data about that web. For example, if you apply a theme to one of your webs, all folders within that web will have the same theme. However, you can apply different themes to the webs on your Web server. When you change a web to a folder, you remove special settings that make that folder a web, and settings such as the theme change to match the "global" theme for the disk-based or server-based web that provides the container for your FrontPage-based subwebs.

Understanding Navigation Structure

You can create files within your web, but the navigation structure that links these files to your web isn't automatically created when the files are created. However, each subweb can have its own home page. A home page is usually the starting page for any web in the navigation structure; but in FrontPage you can create alternate pages that exist at the same navigation level as the home page. You may want to add links to a home page that navigate to home pages of other subwebs that you're maintaining.

The navigation structure contains nodes that link each of the pages in your subwebs and provide pointers to the locations of each page in the navigation structure. The navigation structure for a disk-based web is shown in the following diagram.

Figure 0.5 Conceptualized view of a navigation structure.

The following figure shows the navigation structure in Navigation view.

Figure 0.6 Navigation nodes shown within the navigation structure.

Creating Web Sites Programmatically

Here's a very simple design for a web. The Rogue Cellars company wants to add a subweb called Wines Around the World that will start with pages for two countries, Spain and France. The folder structure will contain the Rogue Cellars web and the folder for the subweb, Wines Around the World, plus the hidden folder _private, and an Images folder. The navigation structure will contain the Wines Around the World home page (index.htm) and the two child pages (Spain.htm and France.htm—the left and right nodes in the navigation structure).

There are two ways to create FrontPage-based webs in Microsoft Visual Basic for Applications. You can use the Add method with the Webs collection, or you can use the MakeWeb method with a WebFolder object to change an existing folder into a web.

Creating a Web Site with the Add Method

Once you've designed how your Web site is going to look and function, you can use the Set statement as shown in the procedure below to create a new web.

Note To run the examples in this topic, you must have a web called "C:\My Documents\My Webs\Rogue Cellars" (for a server running on Microsoft Windows) or "C:\WINNT\Profiles\logon alias\Personal\My Webs\Rogue Cellars" (for a server running on Windows NT). Or, you may substitute a web and files of your choice.

Private Sub Add()
Dim myNewWeb As Web

Set myNewWeb = _
    Webs.Add("C:\My Webs\Rogue Cellars\Wines Around the World")
End Sub

When you create a web with this method, you only create the web and its folder, you don't create a complete Web site with all of the folders, pages, and navigation in place. The next step is adding a home page. The following statement shown in bold adds a home page and is added to the previous procedure.

Private Sub Add()
Dim myNewWeb As Web
Dim myFiles As WebFiles
Dim myUrl As String

Set myNewWeb = _
    Webs.Add("C:\My Webs\Rogue Cellars\Wines Around the World")
Set myFiles = myNewWeb.RootFolder.Files
myFileUrl = _
    "C:\My Webs\Rogue Cellars\Wines Around the World\index.htm"

myFiles.Add(myFileUrl)
End Sub

Because index.htm or default.htm are file names associated with names commonly used as home pages, FrontPage creates the appropriate navigation structure for a home page whenever you use one of these names. However, if you add further pages using the Add method with the WebFile object, you will add pages, but FrontPage will not automatically create the navigation structure for you—you will have to add the navigation structure manually as is illustrated in the following statements shown in bold.

Note The following example creates a new web in the Rogue Cellars web and creates two pages in the new web, index.htm, Spain.htm.

Private Sub AddCompleteWeb()
Dim myNewWeb As Web
Dim myFiles As WebFiles
Dim myUrl As String
Dim myFileOne As String

Set myNewWeb = _
    Webs.Add("C:\My Webs\Rogue Cellars\Wines Around the World")
Set myFiles = myNewWeb.RootFolder.Files
myFileUrl = _
    "C:\My Webs\Rogue Cellars\Wines Around the World\index.htm"

myFiles.Add(myFileUrl)
myFileOne = "C:\My Webs\Rogue Cellars\Wines Around the World\"
myFileOne = myFileOne & "Spain.htm"
myFiles.Add myFileOne
Call myNewWeb.HomeNavigationNode.Children.Add(myFileOne, "Spain", _
    fpStructLeftmostChild)
myNewWeb.ApplyNavigationStructure

End Sub

Notice the last statement in bold—this method applies the changes that you've made to the navigation structure.

There are several constants you can use in the Add method for the Children property, fpStructBaseOnSibling, fpStructLeftmostChild, and fpStructRightmostChild. Very simply, these constants inform FrontPage which position you want to apply to the file in the navigation structure—left, right, or base the position on one of the siblings. Here, myFileOne becomes the leftmost child of the home page. The next step is to add the next page, so that you can view the navigation structure in Navigation view. The following statement shown in bold adds another page and navigation node to the previous web.

Private Sub Add()
Dim myNewWeb As Web
Dim myFiles As WebFiles
Dim myFileUrl As String
Dim myFileOne As String
Dim myFileTwo As String

Set myNewWeb = _
    Webs.Add("C:\My Webs\Rogue Cellars\Wines Around the World")
Set myFiles = myNewWeb.RootFolder.Files
myFileUrl = _
    "C:\My Webs\Rogue Cellars\Wines Around the World\index.htm"

myFiles.Add(myFileUrl)
myFileOne = "C:\My Webs\Rogue Cellars\Wines Around the World\"
myFileOne = myFileOne & "Spain.htm"
myFileTwo = "C:\My Webs\Rogue Cellars\Wines Around the World\"
myFileTwo = myFileTwo & "France.htm"

myFiles.Add myFileOne
myFiles.Add myFileTwo
Call myNewWeb.HomeNavigationNode.Children.Add(myFileOne, "Spain", _
    fpStructLeftmostChild)
Call myNewWeb.HomeNavigationNode.Children.Add(myFileOne, "Spain", _
    fpStructRightmostChild)

myNewWeb.ApplyNavigationStructure

End Sub

You can continue to add pages and navigation nodes to your web in this way until your web is complete. Or, you can create a For loop where you iterate through the web adding the number of pages and navigation nodes you need to complete the web. The following example adds five pages and navigation nodes to a new web in the Rogue Cellars web.

Note Creating, moving, or deleting files and folders while attempting to modify the navigation structure may cause some changes to be lost. First Make the changes to the folder structure of the web, make the navigation structure changes, and then apply the navigation structure to the web.

Private Sub AddDesignerCrystalWeb()
Dim myWeb As Web
Dim myParentWeb As Web
Dim myFolders As WebFolders
Dim myFolder As WebFolder
Dim myFiles As WebFiles
Dim myNewFiles(4) As WebFiles
Dim myChildNode As NavigationNode
Dim myNewFilename As String
Dim myFileURL As String
Dim myCount As Integer
Dim myBaseURL As String
Dim myWebURL As String
Dim myInputMsg As String
Dim myExist As Boolean

Set myParentWeb = _
    Webs.Open ("C:/My Documents/My Webs/Rogue Cellars/")
myParentWeb.Activate

myBaseURL = "C:/My Documents/My Webs/Rogue Cellars/"
myWebURL = myBaseURL & "Rogue Cellars Designer Crystal"
myExist = False
myInputMsg = _
    "All files will have "".htm"" appended. Type a file name: "
Set myFolders = Webs(0).RootFolder.Folders

For Each myFolder In myFolders
    'Check to see if myWebURL already exists.
    If myFolder.IsWeb And myFolder.Url = myWebURL Then
        myExist = True
    End If
Next

'Create myWebURL if it doesn't exist.
If myExist = False Then Webs.Add(myWebURL).Activate
Set myWeb = ActiveWeb
Set myFiles = myWeb.RootFolder.Files

'Create files.
For myCount = 0 To UBound(myNewFiles)
    myNewFilename = InputBox(myInputMsg)
    myFileURL = myWeb.Url & "/" & myNewFilename & ".htm"
    myFiles.Add myFileURL
    myFiles(myFileURL).Edit
Next

'Add to navigation structure.
For myCount = 0 To UBound(myNewFiles)
    'Check if the current page is index.htm, if so, skip it.
    If myFiles(myCount).Title = "index.htm" Then
        myCount = myCount + 1
    End If
    Set myChildNode = _
      myWeb.RootNavigationNode.Children(0)
    'Add navigation node to the current page.
    myChildNode.Children.Add myFiles(myCount).Url, _
        myFiles(myCount).Title, fpStructLeftmostChild
Next
myWeb.ApplyNavigationStructure
End Sub

Creating a Web Site with the MakeWeb Method

If you already have an existing folder that you'd like to convert to a web, you can use the MakeWeb method with a WebFolder object as shown in the following procedure.

Note This procedure assumes that web(0) is the Rogue Cellars web and that it contains a folder called FolderOne.

Private Sub MakeAWeb()
Dim myWeb As Web
Dim myFolder As WebFolder

Set myWeb = Webs(0)
myWeb.Activate
Set myFolder = ActiveWeb.RootFolder.Folders("FolderOne")
myFolder.MakeWeb
End Sub

You will need to create a navigation structure once PageOne is a subweb of Rogue Cellars.


Exploring Procedures In Microsoft FrontPage 2000

Exploring Procedures

This topic is designed to give users, who may be familiar with Microsoft FrontPage, but unfamiliar with Microsoft Visual Basic for Applications, background on some of the basic concepts in a FrontPage-based programming enivronment. Programming in FrontPage Visual Basic for Applications provides you with HTML tools in an Microsoft Office programming environment where you can create procedures that perform a task or a series of tasks. For example, you could:

  • Create a procedure that retrieves data from a Microsoft Access database and displays the data on your web page

  • Publish a Microsoft PowerPoint presentation for automatic updates over the Internet

  • Automatically update a Microsoft Excel spreadsheet with input from users responding to your web site

Click a hyperlink in the following list to move directly to that topic.

Organize code for modular use

Types of procedures

Public and private procedures

Types of procedure calls

Event procedures and arguments

Create a table in FrontPage from an Access database

Multiple projects

Organize code for modular use

Visual Basic procedures provide a way for developers to organize code for modular use. Instead of writing the same calculator function over and over for each program, you can take that segment of code (the calculator function) and compile it into a general program, which can then be accessed by many other programs. In Visual Basic, a block of code is enclosed between a procedure heading and a closure statement—the Sub and End Sub statements.

The basic syntax of a procedure within Visual Basic is shown in the following code sample.

[Private|Public|Static] Sub procedurename(arguments)

statements

End Sub

To run any of the samples of complete code (a code block) follow these steps:

  1. Open FrontPage, select Macro from the Tools menu, and then click Visual Basic Editor.

  2. Double-click Microsoft_FrontPage (or the current project) in the Project window, and expand the Modules folder.

  3. Double-click Module 1 to open the Code window.

  4. Select the code block in the documentation that you want to run, press Ctrl + C to copy the selected area. Click the Microsoft Visual Basic – Microsoft FrontPage button on the Windows taskbar.

  5. Click anywhere in the Code window and press Ctrl + V to paste the sample code.

  6. Click the Run Sub/User Forms button on the toolbar.

Your code will automatically be saved when you close the Visual Basic Editor. For more information on Visual Basic, refer to Understanding Objects, Properties, Methods, and Events in the online documentation Visual Basic Conceptual Topics.

Types of procedures

FrontPage Visual Basic provides two types of procedures, Sub procedures and Function procedures. What's the difference? Sub procedures execute a block of code in response to an event procedure, such as a mouse click or a keystroke, and are void—they perform tasks that do not return any values. Therefore, you can't return a value from within an event procedure.

Note A Sub procedure can be an event procedure, but it can also perform a task without returning a value and without responding to an event.

The following procedure retrieves the version number of FrontPage from with the active web, but doesn't return the version number to any other procedure.

Sub DisplayVersion()
Dim myWeb As Web
Dim myVersion As String

myWeb = "FrontPage version number: " & ActiveWeb.Application.Version
End Sub

A Function procedure also performs tasks, but returns one or more values as arguments. The following code sample returns the version number of FrontPage to the calling procedure GetAppVersion.

Function ReturnVersion(currAppVersion As Variant)
Dim varAppVersion As Variant
    varAppVersion = Application.Version
    ReturnVersion = varAppVersion
End Function

The variable currAppVersion now contains the version number of FrontPage. To access this value in the calling procedure, you could write code similar to the following code sample.

Sub GetAppVersion()
Dim myAppVersion As Variant

MsgBox "This version of FrontPage is version " _
    & ReturnVersion(myAppVersion)
End Sub

Alternatively, you could assign the expression ReturnVersion(varDisplayAppVersion) to a variable and append the variable to the message box statement instead of the function call.

Both Sub and Function procedures can be called to perform their tasks from within other modules or procedures, depending on whether the procedures are declared Public or Private procedures.

Note To use the previous function for more than one module, place the code in the Declarations section of the General procedure.

A macro is a third term used to describe code in Visual Basic for Applications. As a public Sub procedure that doesn't take arguments, a macro may or may not call other Sub or Function procedures, and can be assigned to command bars and shortcut keys or run from the Macro dialog box.

Public and private procedures

Visual Basic provides two ways to access a procedure. By default, procedures are public—they can be called from any other procedure in any module within your application. For example, if you've written a procedure that lists images by file name on a Web page, you would want to declare that procedure public so that you could use it across all of your Web sites. However, if you've written a procedure that edits a specific database, you would want that procedure to be available only to the module that handles editing the database—in that case, you can declare the procedure private. Procedures that have been declared private can only be referenced by other procedures within the same module. The function shown previously has been declared a public function in the following code sample and can be called across modules and projects.

Public Function ReturnVersion(varCurrentAppVersion As Variant)
    statements
End Function

In contrast, a procedure that is used to edit a database should be declared private.

Private Function EditCustomerName(strFirstName As String)
    statements
End Function

Types of procedure calls

How do you programmatically run a procedure? You declare it the same way that you would use a keyword, such as Open. The following procedure calls the ReturnVersion function and includes a local variable, MyVersion, for the value that is passed to the procedure.

Function TestCall(AppVersion As Variant)
Dim MyVersion As Variant
    ReturnVersion(MyVersion)
End Sub

If you didn't have any information to pass from one procedure to another, you would simply declare the procedure name, as shown in the following code sample.

Sub TestCall2()
    DisplayCompanySplashScreen
End Sub

The TestCall2 procedure calls another procedure, DisplayCompanySplashScreen, which doesn't take any arguments or return any values.

Event procedures and arguments

If you want an event, such as clicking a command button, to trigger the execution of code in cases where you would usually pass a value to the calling procedure, you can execute the results from the function rather than pass a variable. Adding the following code shown in bold to the ReturnVersion function initiates the display of the version number for the active application.

Function ReturnVersion(varCurrentAppVersion As Variant)
Dim varAppVersion As Variant
    varAppVersion = Application.System.Version
    varCurrentAppVersion = varAppVersion
    DisplayMsgBox (varCurrentAppVersion)
End Function

The DisplayMsgBox function shown in the following code sample displays the contents of the variable varCurrentAppVersion that was passed from the ReturnVersion function.

Function DisplayMsgBox(varGotAppVersion As Variant)
Dim varDisplayAppVersion As Variant
    VarDisplayAppVersion = varGotAppVersion
    MsgBox "This application is version " _
        & varDisplayAppVersion

An event procedure can now initiate the display of the value that is passed from the ReturnVersion function.

Private Sub CommandButton1_Click()
Dim varThisAppVersion As Variant
    ReturnVersion (varThisAppVersion)
End Sub

Create a table in FrontPage from an Access database

The following procedure combines objects from the Page object model and the Web object model to retreive data from an open Microsoft Access database and insert it into a table on a FrontPage-based web page. The ParseDBTable procedure provides the parameters for the ParseAccessTable function which calls the following functions to create and populate the table:

  • AddDBTableToPage—creates a new table

  • AddDBRow—inserts a row onto the web page

  • AddMemo—retrieves the memos from the Access database, returns them as bookmarks at the bottom of the page below the new table, and returns the URL to the bookmark

Note The Access database, Northwind.mdb, was used for this example. To run the example, you must have references in the Visual Basic Editor to Microsoft DAO 3.6 Object Library and Microsoft Access 9.0 Object Library. You must also open an Access database before running the example, and you must add a blank temporary file called tmp.htm in the active web. If you use a database other than Northwind.mdb, you must specify the database name and table in the ParseDBTable procedure.

Function AddDBTableToPage(myPage As PageWindow, _
    myTableName As String, myFields As Integer)
Dim myTable As FPHTMLTable
Dim myHTMLString As String
Dim myCount As Integer

myHTMLString = "<table border=""2"" id=""myRecordSet_" & _
    myTableName & """>" & vbCrLf
myHTMLString = myHTMLString & "<tr>" & vbCrLf

For myCount = 1 To myFields
    myHTMLString = myHTMLString & "<td id=""myDBField_" & _
        myCount & """> </td>" & vbCrLf
Next myCount

myHTMLString = myHTMLString & "</tr>" & vbCrLf
myHTMLString = myHTMLString & "</table>" & vbCrLf

Call myPage.Document.body.insertAdjacentHTML("BeforeEnd", _
    myHTMLString)

End Function

Function AddDBRow(myDBTable As FPHTMLTable)
Dim myHTMLString As String
Dim myTableRow As FPHTMLTableRow

Set myTableRow = myDBTable.rows(0)

myHTMLString = myTableRow.outerHTML
Call myDBTable.insertAdjacentHTML("BeforeEnd", myHTMLString)

End Function

Function AddMemo(myCurrentPage As PageWindow, myDBMemo As String, _
    myBkMarkField As String, myIndex) As String
Dim myHTMLString As String
Dim myMemoBkMark As String
Dim myBookMark As FPHTMLAnchorElement

myMemoBkMark = myBkMarkField & "_" & myIndex
myHTMLString = "<a name=""" & myMemoBkMark & """> Memo #" & _
    myIndex & "</a>" & vbCrLf

'Add the bookmark to the page.
Call myCurrentPage.Document.body.insertAdjacentHTML("BeforeEnd", _
    myHTMLString)

Set myBookMark = myCurrentPage.Document.all(myMemoBkMark)

'Add the memo text to the page.
Call myCurrentPage.Document.body.insertAdjacentHTML("BeforeEnd", _
    myDBMemo)
AddMemo = "<a href=""#" & myBookMark.Name & """>"

End Function

Function ParseAccessTable(myDBName As String, myTableName As String)
'Access/DAO Declarations.
Dim myDBApp As Access.Application
Dim myRecordSet As DAO.recordset
Dim myDBField As DAO.Field

'FrontPage Page object model declarations.
Dim myPage As PageWindow
Dim myTable As FPHTMLTable
Dim myTableRow As FPHTMLTableRow
Dim myTableCell As FPHTMLTableCell

'Function declarations.
Dim myCount As Integer
Dim myFieldValue As String
Dim myRecordCount As Integer
myRecordCount = 0

'Function constants.
Const myTempPage = "tmp.htm"

'Get the current Access database.
On Error GoTo AccessNotThereYet
    Set myDBApp = GetObject(, "Access.Application")

'Get the database table.
On Error Resume Next
Set myRecordSet = myDBApp.CurrentDb.OpenRecordset(myTableName)

'Add a new page to the current web.
Set myPage = ActiveWeb.LocatePage(myTempPage)
myPage.SaveAs myTableName & ".htm"

'Delete the temporary file from web.
ActiveWeb.LocatePage(myTempPage).File.Delete

'Add a database-ready table to the page with the proper number of fields.
AddDBTableToPage myPage, myTableName, myRecordSet.Fields.Count

'Get a reference to the table.
Set myTable = myPage.Document.all.tags("table").Item(0)

'Populate the first row.
For myCount = 0 To myRecordSet.Fields.Count - 1
    myTable.rows(0).cells(myCount).innerHTML = "<b>" & _
        Trim(myRecordSet.Fields(myCount).Name) & "</b>"
Next

'Populate the rest of the table.
While Not (myRecordSet.EOF)

    AddDBRow myTable
    Set myTableRow = myTable.rows(myTable.rows.Length - 1)

    For myCount = 0 To myRecordSet.Fields.Count - 1
        Set myTableCell = myTableRow.cells(myCount)

        If IsNull(myRecordSet.Fields(myCount)) Then
            myFieldValue = "None"
        Else
            myFieldValue = Trim(myRecordSet.Fields(myCount).Value)
        End If

        If myRecordSet.Fields(myCount).Type = DAO.dbMemo Then
            myFieldValue = AddMemo(myPage, _
                myRecordSet.Fields(myCount).Value, _
                myRecordSet.Fields(myCount).Name, myRecordCount)
        End If

        myTableCell.innerHTML = myFieldValue

    Next myCount
    myRecordSet.MoveNext
    myRecordCount = myRecordCount + 1
Wend

myPage.Save
myDBApp.Quit
Exit Function

AccessNotThereYet:
    Debug.Print Err.Number & ":" & Err.Description
    Resume

End Function

Private Sub ParseDBTable()
Call ParseAccessTable("Northwind.mdb", "Products")
End Sub

Multiple projects

FrontPage doesn't support multiple projects. You can install the Microsoft Office Developer (ODE) to add flexibility to your Visual Basic Editor. ODE provides the capability of creating multiple projects, compiling .dlls, and managing your Visual Basic projects more effectively.


Sharing Microsoft FrontPage Programming Projects

Sharing Programming Projects

Microsoft FrontPage doesn't provide the ability to create multiple projects, so sharing a project may be a little confusing at first glance. You can share your Microsoft FrontPage projects using one of the following three methods:

  • As a ComAddIn.

  • By exporting the .bas, cls, and .frm modules to a directory on your hard drive (or a server location). Then the user can import the modules to their project in FrontPage.

  • Use the Microsoft Office Developer Edition to open the project.

Sharing as a COMAddIn

For a detailed description of how to develop a COM add-in, see the chapter "Add-ins, Templates, Wizards, and Libraries" in the Microsoft Office 2000 Visual Basic Programmer's Guide.

Sharing by exporting the project

You can export your modules from the Visual Basic Editor by selecting the module in the Project window and then pointing to Export File on the File menu. Point the Export File dialog box to the directory you want the file to reside in and FrontPage takes care of the rest.

Note When exporting UserForm files, you must also include the .frx files. This file is used during the import process and does not need to be imported, but does need to be available in the same directory as the other modules.

Sharing by using the Office Developer Edition

The Office Developer Edition adds New Project and Make to the File menu and allows you to create multiple projects in the Visual Basic Editor. Using the Make command, you can compile a project into a .dll to share with others.


Understanding Absolute and Relative URLs in FrontPage 2000

Understanding Absolute and Relative URL Addressing

Microsoft FrontPage uses absolute URL addressing. However, FrontPage does provide a way to change the addressing of URLs between absolute and relative addressing through the MakeRel and MakeAbs methods.

What is an absolute URL?

A URL defines the location of an object. When an URL is absolute, it defines unambiguously where the object is located. For example, http://www.microsoft.com/FrontPage/default.htm is the exact location of the welcome page for Microsot FrontPage. The object, default.htm, is stored in the FrontPage folder or subweb on the web server, www.microsoft.com.

A disk-based web that contains your webs on your hard drive might have a base absolute URL such as file:///C:/My Documents/My Webs or C:/WINNT/Profiles/your logon alias/Personal/My Webs/index.htm.

As Web sites are updated and the structure of a web evolves, documents can often be moved from one location to another in a web. If you're using a relative address, you may break some links. For example, if you have a document that has a hyperlink to an object, you can use an absolute URL to insure that the hyperlink always refers to that object. For example, a document such as file:///C:/My Documents/My Webs/mydocument.htm, may contain an absolute URL that refers to the welcome page, http://www.microsoft.com/FrontPage/default.htm. If the document, default.htm, is moved to another location, the absolute URL for the document will always refer to the object on the web server at www.microsoft.com in the subweb, FrontPage. If the URL for the hyperlink to default.htm is a relative address, the link could be broken if mydocument.htm is moved to a different subweb or main web.

What is a relative URL?

Instead of specifying every piece of a URL that fully defines how to find an object, you can abbreviate a URL to make it “relative” to a current location. Relative URLs are typically used when creating a web site in which the pages in it refer to other pages on the site. A page such as file:///C:/My Documents/My Webs/mydocument.htm can have a relative URL to “newdocument,htm” or to “../My Webs2/default.htm”. In these two cases, the referred addresses for these files are file:///C:/My Documents/My Webs/newdocument.htm and file:///C:/My Documents/My Webs2/default.htm. Notice that the full web server or explicit directory isn’t specified, the location is based on where the document is located.

Relative URLs are very useful, particularly when constructing a site in one place, and then publishing it to another place. For example, you might not want to specify a server name while authoring a web page, because the server name will change when the web is published.

How can an absolute URL be made relative?

URLs can be made relative either to a server or to a page. In order to make a URL relative to a folder or to a web, you need to make the URL relative either to a server or to a page, because FrontPage will treat the URL as if it were being made relative to a page in that folder or web. Each relative URL, combined with its base URL fully specifies where the object is located.

When you have an absolute address such as http://www.microsoft.com/myweb, with an image file called MyPicture.gif residing in the images folder on the web, you can create a relative URL for that address by deciding whether the relative address will refer to a server or a page. For a server relative URL, you’d use “myweb/images/MyPicture.gif”—with the server name as the base for the relative URL, this relative address fully defines the location of the object. For a page relative URL, you’d use “images/MyPicture,gif”—with theserver name and the web name as the base for the relative URL, this relative address fully defines the location of the object. For a folder relative URL, you’d use “MyPicture.gif”—with the server name, web name, and folder name as the base for the relative URL, this relative address fully defines the location of the object.

A folder relative URL can also be specified from a different folder–for example, “../images/MyPicture.gif” could be used if the referring document was in another top level folder on the same web and server. The “..” is the notation used to indicate up one folder level from the current URL address.

Programmatic Access to Relative URLs

Once you've decided whether to use server, web, or folder relative URLs, you can determine which objects to use. For server or web relative URLs, you would be working with methods related to the Web object. For folder relative URLs, you would be working with methods related to the WebFolder object.

Converting relative and absolute URLs

Recommended use for FrontPage is absolute addressing. However, once you have specified relative URL within FrontPage, you can use the MakeAbs method to convert it into an absolute URL. Similarly, if you have an absolute URL, and you want to insert a reference into a document as a relative URL, you can use MakeRel to convert the address to a relative address. You can also use the MakeAbs and MakeRel methods to convert a hyperlink for a Web, WebFolder, WebFile, NavigationNode, or IHTMLDocument2 object.


Exploring the FrontPage Object Model

Exploring the Object Model in FrontPage

The Microsoft FrontPage object model consists of three separate object models—the Application object model, the Web object model, and the Page object model that is based on Microsoft Internet Explorer 4.0's Document object model.

These object models are designed to provide Web designers with a rich set of programmability interfaces to manage individual HTML documents and FrontPage-based webs. The object models parallel other Microsoft Office application object models as closely as possible in order to leverage the experience and knowledge users currently have with other programmable Office applications. In addition, the Page object model is compatible with the Document object model of Microsoft Internet Explorer 4.0 and later. The Page object model also leverages the experience and knowledge of web developers who program Dynamic HTML using script.

Differences in the Programmable Interfaces

FrontPage 2000 provides a design-time user experience versus a run-time user experience, because HTML pages are usually viewed in a browser rather than in FrontPage. Other Office applications provide a run-time user experience that contains an environment where the developer can create solutions for the user that run within the application. With FrontPage 2000, you can create utilities for use during the design phase of the HTML document or Web site and, once you have designed and built your web site, you can use VBScript, JScript, and DHTML to create interactive effects for use during run-time when the page is viewed in a browser.

Application Object Model Functionality

The Application object is the top-level object in the Web object model hierarchy and provides access to all of the objects in FrontPage, such as an active web, active page, add-ins, command bars, system, webs, and web.

FrontPage Page Object Model Functionality and Restrictions

The Page object model has all of the functionality of the Internet Explorer Document object model except for the restrictions previously noted and those noted in the following topics.

HTML Events not Supported by FrontPage2000

HTML Methods not Supported by FrontPage2000

HTML Properties not Supported by FrontPage2000

Web Object Model Functionality

The Web object model provides programmatic management of multiple FrontPage-based Web sites and their contents. This object model is based on conventions used by Microsoft Office Applications Suite and Microsoft Visual Basic for Applications. The Web object model also provides support for Microsoft Visual SourceSafe when accessed through FrontPage.

Object Model Interaction

Most of the programming for FrontPage-based webs will contain a combination of Web and Page object model programming elements. For additional information and examples of this, click a topic in the following list.

Accessing Framesets with Microsoft Visual Basic

Modifying Pages Programmatically

Programming Dynamic Elements


Accessing FrontPage Framesets With Microsoft Visual Basic

Accessing Framesets with Microsoft Visual Basic

Frames are an important part in the design of a web. FrontPage 2000 provides support for programming the content of frames. Click one of the following links for more information on a particular topic.

Exploring Frames

Role of a Frameset

Accessing HTML Tags

Dynamic Framesources

Iterating all Frames in a PageWindow

Changing Meta Tag Content to Another Character Set

Exploring Frames

Accessing frames within a frameset in FrontPage is relatively straightforward as long as you keep in mind that each frame accesses its own page and that you access the contents of each page through a Page object model object. The two windows involved with displaying frames area PageWindow object and an FPHTMLWindow2 object. The equivalent expression to access the contents in the window associated with the active frame is Set myActiveFrameInFrameset = ActivePageWindow.Document. The ActivePageWindow object accesses the page window for the frame, and the Document object accesses the FPHTMLWindow2 object.

Note You may get permission denied errors if you try to access objects while in HTML view. When you want to add code or text to a document object, you must have the FpPageViewMode constant for the ViewMode property set to fpPageViewNormal. The value for view mode cannot be set to fpPageViewHtml or fpPageViewPreview. Alternatively, in the User Interface (UI), you cannot have the HTML tab or the Preview tab open in Page view in FrontPage.

Role of a Frameset

A framset is the container for all of the frames in a web window. Each frame is contained in an individual page window and has an individual page associated with it. By accessing the FrameWindow object from the Web object model, you access an FPHTMLWindow2 object that contains the frame page document. From these objects you can access the windows, documents, and frames of the frameset. In the following statement, myFrameset is an FPHTMLWindow2 object that returns the frames page document. From this object, you can access the <frame> and <frameset> tags, or the window or document objects.

Set myFrameset = ActivePageWindow.FrameWindow

This statement returns an FPHTMLWindow2 object through the Page object model. The Document property of myFrameset accesses the Page object model for the page that is equivalent to accessing the Frames Page HTML tab in Page view in FrontPage.

Note The Frames Page HTML and No Frames tabs are only available when frames exist on the current page.

Accessing HTML Tags

You can access the same information that a frames tag accesses by declaring an object as a FPHTMLFrameElement. Some of the properties and methods available for this object include border, borderColor, click, frameBorder, frameSpacing, innerHTML, innerText, insertAdjecentHTML, and insertAdjacentText.

Dim myFramesElements() As FPHTMLFrameElement

You can access the information for a frameset tag by declaring an object a FPHTMLFramesetSite object.

Dim myFramesetSite As FPHTMLFramesetSite

Dynamic Framesources

You can dynamically change the framesource in the HTML code by using the following statements. This code sets the framesource to a new URL, Inventory_1stQuarter.htm.

Dim myDoc As Object

Set myDoc = ActivePageWindow.FrameWindow.Document

myDoc.all.tags("frame").Item(0).src = _
    "Inventory_1stQuarter.htm"

Iterating all Frames in a PageWindow

To access the properties of the frameset elements that reside in a particular frames page, you must access the FPHTMLDocument object through the Document property. The following example iterates through the frameset and frame elements for the active frameset in FrontPage. The frameset array (myFSElements) comprises each <FRAMESET> tag on the frames page. The frames array (myFramesElements) comprises each <FRAME> tag on the frames page. The frame windows array (myFramesWindows) comprises each FPHTMLWindow2 object that points to each frame. You populate each of the arrays by iterating through their respective tags or objects. Once the arrays are populated, you change the frameSpacing property in the frameset element to "10", the borderColor property to "red", and change various properties in the document.

Private Sub AccessFramesPage()
Dim myFPWindow As FPHTMLWindow2
Dim myFSElements() As IHTMLFrameSetElement
Dim myFramesWindows() As FPHTMLWindow2
Dim myFramesElements() As FPHTMLFrameElement
Dim myStyle As FPHTMLStyle
Dim i As Integer

Set myFPWindow = ActivePageWindow.FrameWindow
ReDim myFSElements(myFPWindow.Document.all.tags("FRAMESET").length)
ReDim myFramesElements(myFPWindow.Document.all.tags("FRAME").length)
ReDim myFramesWindows(myFPWindow.frames.length)

For i = 0 To UBound(myFSElements)
    Set myFSElements(i) = _
        myFPWindow.Document.all.tags("FRAMESET").Item(i)
Next i

i = 0
For i = 0 To UBound(myFramesWindows)
    Set myFramesWindows(i) = myFPWindow.frames(i)
Next i

i = 0
For i = 0 To UBound(myFramesElements)
    Set myFramesElements(i) = _
        myFPWindow.Document.all.tags("FRAME").Item(i)
Next i

myFSElements(0).frameSpacing = "10"
myFramesElements(0).borderColor = "red"

With myFramesWindows(2).Document
    .bgColor = "green"
    .body.innerHTML = "<p id=""cool""> Added by FP Programmability"
    Set myStyle = .all.cool.style
        myStyle.backgroundColor = "white"
        myStyle.display = False
        myStyle.textDecorationUnderline = True
        myStyle.Font = "Tahoma, 24"
        myStyle.fontStyle = "italic"
End With
End Sub

Changing Meta Tag Content to Another Character Set

You can change all of the content-type META Tags to a different character set (Central European) as shown in the following code sample. The current character set is shown in the Language Settings dialog box (available for Page Properties).

Note The entire content-type META Tag contains a string similar to the following:

content = "text/html; charset = windows-1252

The character set is "windows-1252" and is the default character set for U.S. English.

Each time the program iterates through the loop, you access the next frame in the frameWindow object, which is the same as accessing each frames tag in HTML in succession. However, the frames collection does not support the For..each constuct. You cannot access HTTP-EQUIV type meta tags via their name, you must use an index instead as shown in the following example.The expression beginning with myContentType.Content sets the character set to Central European.

Note FrontPage places the content type in META Tag zero.

Private Sub ChangeCharSet()
Dim myFrames As IHTMLFramesCollection2
Dim myFrame As FPHTMLWindow2
Dim myHTTPEquiv As String
Dim myContentType As Object
Dim myCount As Integer

Set myFrames = ActivePageWindow.FrameWindow.frames
Set myFrame = ActivePageWindow.FrameWindow.frames(0)
myHTTPEquiv = 0

For myCount = 0 To myFrames.Length - 1
    Set myFrame = myFrames(myCount)
    Set myContentType = _
        myFrame.Document.all.tags("meta").Item(myHTTPEquiv)
    myContentType.content = _
        "text/html; charset=iso-8859-2"
Next myCount
End Sub


Accessing the FrontPage Object Model from Design-Time Controls

Accessing the Object Model in FrontPage from Design-Time Controls

A design-time control (DTC) is one of a class of ActiveX controls that is exclusively used at design-time as an aid to authoring web content. DTCs function just like embedded wizards—they can be edited to modify the output that the DTC generates on the web page. Once the file is closed, the DTC becomes inactive—the text that the DTC generated has been embedded into the file.

How are design-time controls different from ActiveX controls?

Design-time controls do not contain a binary run-time component, but do have a special interface that provides the ability for the design-time control to persist and generate text. Design-time controls and ActiveX controls can co-exist on the same web page. For more information on DTCs refer to the documentation on the Microsoft workshop Web site for design-time controls.

How do design-time controls differ from Visual InterDev?

FrontPage and Microsoft Visual InterDev are compatible in most areas. For design-time controls, FrontPage provides full access to the Document object model that's available in Microsoft Internet Explorer. The Web object model is also available for design-time controls and provides a rich array of objects, events, methods, and properties. FrontPage also provides support for removing tags (or text) that is inserted into a document by design-time controls.

Properties supported by FrontPage that are not supported by Microsoft Visual InterDev:

  • Preview—returns a string containing the controls preview text.

  • Tag—returns the tag context for the preview string.

Built-in options in Visual InterDev that FrontPage doesn't support:

  • QueryBuilder

  • Data connections

  • Visual InterDev object model for .asp pages

How to access the FrontPage object model from a design-time control

A design-time control is a type of ActiveX control, and thus accesses its host's object model similarly to other controls (see FPHTMLObjectElement object). The design-time control has a UserControl property that returns the UserControl object. This object in turn has an Extender property that returns the environment where the ActiveX control resides. The expression, UserControl.extender returns the environment for the specified DTC.

The Extender property returns FPHTMLObjectElement object and provides access to all of the properties and methods in the FPHTMLObjectElement object. One of these properties is the Document property that accesses the Page object model for the document where the design-time control resides. The following statements illustrate how to access the Document property from a DTC.

Dim myDTC As FPHTMLObjectElement
Dim myDoc As FPHTMLDocument
Dim myPageWindow As PageWindow

Set myDTC = UserControl.Extender
Set myDocument = myDTC.document
Set myPageWindow = myDoc.parentWindow.external

The last Set statement illustrates how to access the Web object model from the Page object model.


Coding in a Windowless Environment

In Microsoft FrontPage, it is possible to create a windowless environment to cut down on User Interface (UI) overhead, but there are some drawbacks to working in such an environment. For example, opening a page to fpPageViewNoWindow with the ViewMode property, creates a windowless environment where Window elements that require the UI won't work corretly. If you open a page without a window and try to access it using code such as PageWindow.Document.ParentWindow, the resulting code returns nothing instead of returning an FPHTMLWindow2 object. The following statements provide access to windowless pages.

Application.LocatePage(DocumentUrl As String, _
    ViewMode As FpPageViewMode) As PageWindow
Web.LocatePage(DocumentUrl As String, ViewMode As FPPageViewMode) _
    As PageWindow
File.Edit(ViewMode As FpPageViewMode) As PageWindow

The following table describes the PageWindow methods and properties and the objects or error messages they return. Some methods and properties of the PageWindow object are disabled in a windowless environment and will return the results shown in the following table.

Disabled Method or Property of the PageWindow Object | Returned Object or Error Message
ActiveDocument | Returns "object or with variable not set" error message.
ActiveFrameWindow | Returns "object or with variable not set" error message.
Caption | Returns the URL for the PageWindow object.
Document | Returns a Document object.
File
  • Returns a File object.
ReadyState | Returns the ready state of the document.
ViewMode | This property can not be set. It returns the constant fpViewModeNoWindow.
Visible | Returns False.
Web Returns the Web object if the object was located using the following statements.

Web.LocatePage

File.Edit
ApplyTheme | Returns a run-time error.
Close(ForceSave) | Closes the page window.
Refresh(ForceSave) | Refreshes the page window.
Save(ForceOverwrite) | Saves the page window.
SaveAs(ForceOverwrite) | Saves the page window to a new URL.


Modifying Pages Programmatically

This topic illustrates how to work with the Document object elements within the Web object model environment, either to change the contents of a page or simply to access the contents of a page for verification.

Microsoft Visual Basic is a powerful tool that you can use to modify content in your web pages. As you browse through the Object Browser, you'll see many of the same types of components that you're familiar with in Microsoft Internet Explorer.

Tip To only view the programming elements that are compatible with the Page object model of FrontPage, select "FrontPageEditor" as the object library in the Object Browser.

You can access the HTML elements of a page using the ActiveDocument or Document properties that return the document object via the PageWindow object. For example, the following statement changes the color of the background for the page in the active page window.

ActivePageWindow.Document.bgColor = "DarkBlue"

The following example checks for a specific hyperlink (index.htm) within the active document. If the hyperlink is found, the procedure exits, if the hyperlink isn't found, the procedure first checks if the active document is index.htm and, if not, the hyperlink is added at the end of the document.

Private Sub VerifyIndexLink()
Dim myDoc As FPHTMLDocument
Dim myLinks As Variant
Dim myLink As Variant
Dim myNumberOfLinks As Integer
Dim myAddLink As Boolean
Dim myLinkName As String
Dim myLinkName2 As String

Set myDoc = ActivePageWindow.Document
Set myLinks = myDoc.Links
myNumberOfLinks = myLinks.length
myLinkName = "index.htm"
myLinkName2 = """" & myLinkName & """"

For Each myLink In myLinks
    If myLink = myLinkName Then
        myAddLink = True
        Exit For
    End If
Next

If myAddLink = False And myDoc.nameProp <> "index" Then
    Call myDoc.body.insertAdjacentHTML("BeforeEnd", "<a href=" _
        & myLinkName2 & ">" & myLinkName & "</a>")
    ActivePageWindow.Save
End If
End Sub

Tip Notice that in the last If statement the active page window is saved before exiting the procedure. This would be a good statement to add to the OnPageClose event.


Using Enumerated Types in FrontPage

Compared to other Microsoft Office applications, Microsoft FrontPage uses very few constants. To learn about a constant, click it in the following table.

Constant | Enumerated Constant
FpPageViewMode | fpPageViewDefault fpPageViewHtml fpPageViewNoFrames fpPageViewNormal fpPageViewNoWindow fpPageViewPreview
FpSharedBorders | fpBorderAll fpBorderBottom fpBorderLeft fpBorderRight fpBorderTop
FpStructModType | fpStructBaseOnSibling fpStructLeftmostChild fpStructRightmostChild
FpThemeProperties | fpThemeActiveGraphics fpThemeBackgroundImage fpThemeCSS fpThemeDefaultSettings fpThemeName fpThemeNoBackgroundImage fpThemeNoCSS fpThemeNormalColors fpThemeNormalGraphics fpThemePropertiesAll fpThemePropertiesNone fpThemeVividColors
FpWebDeleteFlags | fpDeleteEntireWeb fpDeleteFrontPageInfoFromWeb
FpWebPublishFlags | fpPublishAddToExistingWeb fpPublishCopySubwebs fpPublishIncremental fpPublishNone
FpWebViewMode | fpWebViewAllFiles fpWebViewBrokenLinks fpWebViewFolders fpWebViewLinks fpWebViewPage fpWebViewSiteSummary fpWebViewStructure fpWebViewTodo


Understanding WebWindows and PageWindows

In Microsoft Internet Explorer, the window object is the root of the object hierarchy. In Microsoft FrontPage, the Application object is the root of the object hierarchy and the WebWindow object is an object in the third tier of the object hierarchy belonging to the collection of WebWindows (second tier). The Document property is accessed via the PageWindow object (belonging to the collection of PageWindows), whose parent is the WebWindow object. The object hierarchy for the WebWindows collection is shown in the following diagram.

What is a WebWindow object?

A WebWindow object is the window container for the web. When you open a web in FrontPage, you see the web in its "web" window. FrontPage opens a new window for each web you open.

What is a PageWindow object?

A PageWindow object is the container for the web page. When you open a page in a web window, that page is contained in a page window (visible in the right pane). FrontPage opens a new page window for each page you open; however each PageWindow object is contained within the WebWindow object for the individual web. Each page that you've opened is visible on the Windows menu in FrontPage.

Where does the Document object fit in?

The Document object contains the HTML elements for a page. The elements for the document are available using an expression such as ActivePageWindow.Document.element where element is one of the HTML elements available in FrontPage.


Managing Publishing with MetaTags

Automate publishing your web by using a combination of events such as OnBeforeWebPublishing and meta data that can be obtained from accessing the data in the Properties collection. For example, before publishing a web, you might want to check the meta data for all of the pages in the web. To check if Microsoft FrontPage generated all of the pages in your web, use the following code in the OnBeforeWebPublishing event, along with an event handler.

Private Sub CheckIfFP()
Dim myFiles As WebFiles
Dim myFile As WebFile
Dim myMetaTags As MetaTags
Dim myMetaTag As Variant

Set myFiles = ActiveWeb.RootFolder.Files

For Each myFile In myFiles
    Set myMetaTags = myFile.MetaTags
    'Check for any text files.
    If myMetaTags.Count = 0 And _
        myFile.Extension <> ".asa" Then
        MsgBox myFile.Name & " was not generated by FrontPage."
    End If
    'Check all web pages.
    For Each myMetaTag In myMetaTags
        If myMetaTag = "generator" Then
          If myFile.Properties("vti_generator") = _
            "Microsoft FrontPage 4.0" Then
            Exit For
          Else
            MsgBox myFile.Name & " was not generated by FrontPage."
          End If
        End If
    Next
Next
End Sub

You can also check the value of the vti_donotpublish property key before publishing. If the document is a draft or a document that isn't to be published, the vti_donotpublish property key will be set to True. The following example checks the value of the vti_donotpublish property key.

Dim myFiles As WebFiles
Dim myFile As WebFile

For Each myFile In myFiles
    If myFile.Properties("vti_donotpublish") = True Then
        MsgBox "Do not publish " & myFile.Name
    End If
Next

The vti_donotpublish property key can be used to disable publishing. When publishing is complete, the file will not be published to the server. The following example disables publishing for the first file in the Files collection.

Sub PublishThisFile(myFileName As String, myStatus As Boolean)
Dim myFile As WebFile

Set myFile = ActiveWeb.LocateFile(myFileName)

Call myFile.Properties.Add("vti_donotpublish", Not (myStatus))
myFile.Properties.ApplyChanges
End Sub

Private Sub PublishFile()
PublishThisFile Activeweb.RootFolder.Files(0), False
End Sub


Programming Dynamic Elements in FrontPage 2000

Programming Dynamic Elements

The objects, methods, and properties in Microsoft Internet Explorer are usually designed for run-time use. In Microsoft FrontPage, most of the elements are designed for design-time only. You can programmatically add content to an existing document, access selections on a page, create a scripting element, or modify an existing table. Click one of the following links to move directly to that subject.

Adding Content to a Document Using a TextRange

Accessing User Selections Using a TextRange

Creating a Scripting Element

Accessing Tables

Adding Content to a Document Using a TextRange

You can programmatically add HTML content to a web page by creating a text range object and adding the new content to the page as shown in the following example. The text range object is created from the myDocument body object. If the value in myClearPage is true, then the entire content between the <Body></Body> tags is replaced with the new HTML content, otherwise the new content is appended to the original content.

Public Function AddHTMLToPage(myDocument As Object, _
    myHTMLText As String, myClearPage As Boolean) As Boolean
Dim myRange As Object
Dim myBodyText As Object

On Error GoTo CannotAddHTML

'Create a TextRange object
If myClearPage Then
    Set myRange = _
        myDocument.all.tags("BODY").Item(0).createTextRange
    'Clear the current document
        Call myRange.pasteHTML("")
    myRange.collapse False
    Set myRange = Nothing
End If

Set myBodyText = myDocument.all.tags("BODY").Item(0)
myBodyText.innerHTML = myBodyText.innerHTML & myHTMLText & vbCrLf

AddHTMLToPage = True
Exit Function

CannotAddHTML:
AddHTMLToPage = False
End Function

Sub AddNewHTML()
Dim myHTMLString as String
Dim myBodyElement As Object

myHTMLString = "<B> <I> New Sale on Vintage Wines! </I> </B>" & vbCr

If AddHTMLToPage(ActivePageWindow.Document, myHTMLString, True) Then
    Set myBodyElement = _
      ActivePageWindow.Document.all.tags("BODY").Item(0)
End If
End Sub

Accessing User Selections Using a TextRange

You can use the IHTMLTxtRange object to select HTML objects or manipulate a user selection on a specified document. The following example applies a background color to the current selection.

Private Sub ApplyStyleToSelection()
Dim myRange As IHTMLTxtRange

Set myRange = ActiveDocument.selection.createRange

myRange.parentElement.style.backgroundColor = "SkyBlue"
End Sub

Adding Script to a Page

Scripting in Visual Basic for FrontPage 2000 is easy. Just load the script into a string variable and append the string to the <Head> tag for the page. (The <Head> tag is accessed using an IHTMLElement object). Once the string has been added to the page, it is a valid scripting element and can be accessed through the FPHTMLScriptElement object and modified. The following code adds a script element to the current page, verifies that the script was added, adds a query to the user with OK and Cancel buttons, and then prints some of the script element properties to the Immediate window in the Visual Basic Editor.

Private Sub CreateAScript()
Dim myScriptElement As FPHTMLScriptElement
Dim myHTag As IHTMLElement
Dim myBodyTag As IHTMLElement
Dim myBodyString As String
Dim myHTMLString As String
Dim myText As String

'Build a script tag construct.
myHTMLString = myHTMLString & "<script language=""VBScript"">" _
  & vbCrLf
myHTMLString = myHTMLString & "Function doOK" & vbCrLf
myHTMLString = myHTMLString & _
  "msgbox ""Please wait, an order form is being generated...""" & _
  vbCrLf
myHTMLString = myHTMLString & "End Function" & vbCrLf & vbCrLf
myHTMLString = myHTMLString & "Function doCancel" & vbCrLf
myHTMLString = myHTMLString & _
  "msgbox ""Exiting ordering process.""" & vbCrLf
myHTMLString = myHTMLString & "End Function" & vbCrLf
myHTMLString = myHTMLString & "</script>" & vbCrLf

'Build a call tag construct.
myBodyString = "<CENTER>" & vbCrLf
myBodyString = myBodyString & _
  "<BUTTON onclick=""doOK()"">OK</BUTTON>" & vbTab
myBodyString = myBodyString & _
  "<BUTTON onclick=""doCancel()"">Cancel</BUTTON>" & vbCrLf
myBodyString = myBodyString & "</CENTER>"

'Add text to the document
myText = "I'd like to order some vintage wines."

'Access the <HEAD> tag.
Set myHTag = ActivePageWindow.Document.all.tags("HEAD").Item(0)

'Append the script element to the <Head> tag(myHTag).
myHTag.innerHTML = myHTag.innerHTML & myHTMLString

'Verify that the script element was added.
If ActivePageWindow.Document.scripts.length = 1 Then
    'Access the script element just added.
    Set myScriptElement = ActivePageWindow.Document.scripts(0)

    'Print script element properties to the Immediate window.
    'JScript only: the next statement gets the FOR= attribute from
    'the JScript, otherwise an empty string prints in the Immediate
    'window.
    Debug.Print myScriptElement.htmlFor

    'Retrieve the content of the script.
    Debug.Print myScriptElement.outerHTML

    'Check scripting language.
    Debug.Print myScriptElement.language
End If

'Add a query to the user and call the script element.
ActiveDocument.body.insertAdjacentHTML "BeforeEnd", _
  "<B><I>" & myText & "</B></I><P>" & myBodyString
End Sub

Accessing Tables

Anyone who has created tables and worked with their contents in HTML will find it easy to use Visual Basic to access tables. The following program accesses a table on the current page and inserts a cell into the table.

Sub AccessTables()
Dim myTable As FPHTMLTable
Dim myRow As FPHTMLTableRow
Dim myCell As FPHTMLTableCell

'Get the table.
Set myTable = ActiveDocument.all.tags("TABLE").Item(0)

'Get the first row.
Set myRow = myTable.rows(0)
MsgBox myRow.cells.Length

'Get the first cell.
Set myCell = myRow.cells(0)
MsgBox myCell.Width

'Add a new cell to the first row.
Set myCell = myTable.rows(0).insertCell(myRow.cells.Length)
End Sub


Using to Events to Control Actions in FrontPage 2000

Using Events to Control Actions

There are two types of events in Microsoft FrontPage, events that are driven off the Application object model and events that are driven off the Page object model. The events for the Application object model can be used to control under what conditions a web is published, whether you want to save a page whenever the OnPageClose event is fired, or whether you want to set styles, fonts, or backgrounds whenever a new page is created. For more information on the Application object model events, click one of the events in the following list.

OnAfterPageSave | OnPageNew
OnBeforePageSave | OnPageOpen
OnAfterWebPublish | OnWebClose
OnBeforeWebPublish | OnWebNew
OnPageClose | OnWebOpen

In the Microsoft Internet Explorer DHTML object model, event handlers are created using one of the following methods:

  • Create a procedure or function within a script tag

  • Use a FOR= attribute inside a script tag

  • Use FrontPage events and class modules

You can declare an event handler function by creating a procedure or function inside of a script tag and then define an "On*" attribute that calls that procedure for the element you that you want to generate the events. For example, to catch a mouse click on an anchor you could use the HTML code shown in the following example.

<html>
<head>
<script language="VBScript">
sub test
msgbox "You clicked"
End Sub
</script>
</head>
<body>
<a href="CatchMouse.htm" onclick="CatchMe"> This is an anchor, click here</a>
</body>
</html>

Another way to declare event handling code is to create a script tag with a FOR=attribute, as shown in the following example.

<SCRIPT FOR=myanchor EVENT=onclick LANGUAGE="VBScript">
msgbox "You Clicked"
</SCRIPT>
<a id="myanchor" href="CatchMouse.htm" onclick="CatchMe"> this is an anchor, click on it </a>

However, in the FrontPage Page object model, you're programming with events and objects that are compatible with Internet Explorer, but for use at design-time. To program events for run-time, you can use the standard Microsoft Visual Basic 5.0 keywords to access the Page object model events just as you would to access the Web object model events. This method combines the two techniques described previously. The following example catches the OnClick event for a hyperlink in FrontPage.

In the Visual Basic Editor, insert a class module and name it CatchOnClick. Add the following code to the class class module.

Dim WithEvents eAnchor As FPHTMLAnchorElement
Dim WithEvents eDoc As FPHTMLDocument
Dim e As IHTMLEventObj

Private Sub Class_Initialize()
Set eDoc = ActiveDocument
Set eAnchor = eDoc.links(0)
End Sub

Private Function eAnchor_onclick() As Boolean
Set e = eAnchor.Document.parentWindow.event
If (MsgBox("OnClick Event for " & e.srcElement.tagName & _
    " would you like to cancel the event bubbling?", _
    vbYesNo) = vbYes) Then
    e.cancelBubble = True
    e.returnValue = False
Else
    e.cancelBubble = False
    e.returnValue = True
End If
End Function

Private Function eDoc_onclick() As Boolean
MsgBox "OnClick event for the Document object"
End Function

Next add a standard module and add the following code.

Public e As CatchOnClick
Sub GetClick()
Set e = New CatchOnClick
End Sub

Note To run the example, perform the following steps:

  • Add a hyperlink to a page in FrontPage

  • Run the GetClick procedure to create a global instance of the CatchOnClick event handler class

  • Click the hyperlink

A prompt displays stating that the OnClick event fired. The prompt also queries the user—should the program pass the event on up the event chain? If Yes is chosen, the OnClick event is passed up to the document object to be handled.

To control which document object the event is passed to, you must set both the cancelBubble and returnValue events. The cancleBubble event works to cancel the event from going any farther up the event chain. Set the cancelBubble property for the IHTMLEventObj to True when you don't want the OnClick event to be passed up to the next level of OnClick events, otherwise, set the cancelBubble property to False. For example, if you have an image that has an OnClick event placed on a document, which also has an OnClick event, you would set the cancelBubble property for the IHTMLEventObj object to True for the image, if you don't want the OnClick event to be passed on up to the document OnClick event.

The returnValue propertyis used to control the default action taken by FrontPage when an event fires. Using the previous example of an image placed on a document, if the returnValue property for the IHTMLEventObject for the image is set to False in the OnClick event, then the right-click context menu would be disabled (because the right-click context menu is the default action for the OnClick event).


Managing Source Control Projects in FrontPage 2000

Managing Source Control Projects

Microsoft FrontPage provides two methods of versioning, FrontPage Light Weight source control (also known as Microsoft Office-style locking or FrontPage-based locking) and Microsoft Visual SourceSafe. FrontPage Light Weight source control is the default versioning method for source control projects in FrontPage.

Versioning provides a measure of control over users who maintain pages on your Web sites. Both source control methods provide checkin, checkout, undocheckout. Visual SourceSafe provides other versioning capabilities, such as version tracking and rollback features.

Creating a source control project

To create a new source control project, you set the RevisionControlProject property to the path of the project (for Visual SourceSafe) or to <FrontPage-based Locking> as shown in the following statement.

ActiveWeb.RevisionControlProject = "<FrontPage-based Locking>"

Assuming that the string "$/Rogue Cellars" is a valid Visual SourceSafe project, the following statement assigns the active web to a Visual SourceSafe project.

ActiveWeb.RevisionControlProject = "$/Rogue Cellars/Inventory"

The following example creates a source control project and checks out two files.

Note To run this example, you must have a web called "C:\My Documents\My Webs\Rogue Cellars" (for a server running on Microsoft Windows) or "C:\WINNT\Profiles\logon alias\Personal\My Webs\Rogue Cellars" (for a server running on Windows NT). You may create two files called "index.htm" and "footnote.htm" or substitute file names of your choice.

Private Sub CreateSourceControl()
Dim myWeb As Web
Dim myProject As String
Dim myFile1 As WebFile
Dim myFile2 As WebFile

Set myWeb = Webs.Open("C:\My Documents\My Webs\Rogue Cellars")
Set myFile1 = myWeb.RootFolder.Files("index.htm")
Set myFile2 = myWeb.RootFolder.Files("footnote.htm")

myProject = "<FrontPage-based Locking>"

myWeb.RevisionControlProject = myProject
myFile1.Checkout
myFile2.Checkout
End Sub

The Checkout method provides a Boolean force checkout argument for administrators.

Removing a source control project

Once a project is completed, you may decide to remove versioning. To do this, set the RevisionControlProject property to an empty string ("") as shown in the following statement.

myWeb.RevisionControlProject = ""

Switching between FrontPage Light Weight and Visual SourceSafe projects

To switch between these two types of versioning, you must first set the RevisionControlProject property to an empty string ("") as shown in the following statement.

myWeb.RevisionControlProject = ""


Microsoft FrontPage 2000 Objects

Microsoft FrontPage Objects

Files collection (File object)
Folders collection (Folder object)

NavigationNodes collection (NavigationNode)
Themes collection (Themes)
WebWindows collection (WebWindow)

Legend

yellow box Object and collection
bluebox Object only


OnAfterPageSave Event

Occurs after a page is saved.

Syntax

Private Sub Application_OnAfterPageSave(pPage As PageWindow, _

Success As Boolean)

pPage Required PageWindow. A PageWindow object.

Success Required Boolean. True if the PageWindow object was successfully saved.

Remarks

The OnAfterPageSave event is associated with the Application object. After the user saves a page or closes Microsoft FrontPage, the OnAfterPageSave event fires and executes the code that you specified within the event procedure.


OnAfterPageSave Event Example

This example displays a message box after the page has been saved and displays the file name of the page.

Note To run this example, you must have at least one open web and one open page within that web.

Create a form called frmLaunchEvents.frm and add two buttons, a button called cmdSave, and a button called cmdCancel. Add the following code to the Declarations section of the form code window.

Option Explicit
Private WithEvents eFPApplication As Application
Private pPage As PageWindow

Add the following code to the UserForm_Initialize section of the code window.

Private Sub UserForm_Initialize()
Set eFPApplication = New Application
End Sub

Add the following code to the cmdSave_Click section of the code window.

Private Sub cmdSave_Click()
Dim myPageWindow As PageWindow

Set myPageWindow = ActiveWeb.ActiveWebWindow.ActivePageWindow
myPageWindow.Save
End Sub

Add the following code to the cmdCancel_Click section of the code window.

Private Sub cmdCancel_Click()
'Hide the form.
frmLaunchEvents.Hide
Exit Sub
End Sub

Add the following code to the eFPApplication_OnAfterPageSave section of the code window.

Private Sub eFPApplication_OnAfterPageSave(ByVal pPage As _
    PageWindow, Success As Boolean)
If Success = True Then
    MsgBox "The following page was saved: " & pPage.File.Name
Else: MsgBox "There was a problem with saving your page: " & _
    pPage.File.Name
End If
End Sub


OnAfterWebPublish Event

Occurs after a web is published.

Syntax

Private Sub Application_OnAfterWebPublish(pWeb As Web, Success As Boolean)

pWeb Required Web. The specified Web object.

Success Required Boolean. True if the specified web was successfully published.

Remarks

The OnAfterWebPublish event is associated with the Application object. After the user publishes a web in Microsoft FrontPage, the OnAfterWebPublish event fires and executes the code that you specified within the event procedure.


OnAfterWebPublish Event Example

This example creates a property with the value of True after a web has been published.

Note To run this example you must have one web open. This example uses a web called Rogue Cellars. You can create a web called Rogue Cellars, or you can substitute a web of your choice in the following code sample.

Create a form called frmLaunchEvents.frm and add two command buttons, a button called cmdPublishWeb, and a button called cmdCancel. Add the following code to the Declarations section of a form code window.

Option Explicit
Private WithEvents eFPApplication As Application
Private pPage As PageWindow

Add the following code to the UserForm_Initialize section of the code window.

Private Sub UserForm_Initialize()
Set eFPApplication = New Application
End Sub

Add the following code to the cmdPublishWeb_Click section of the code window.

Private Sub cmdPublishWeb_Click()
ActiveWeb.Publish "C:\My Documents\My Webs\Rogue Cellars"
End Sub

Add the following code to the cmdCancel_Click section of the code window.

Private Sub cmdCancel_Click()
'Hide the form.
frmLaunchEvents.Hide
Exit Sub
End Sub

Add the following code to the eFPApplication_OnAfterWebPublish section of the code window. This code adds a property called Published to the web that contains the value True.

Private Sub eFPApplication_OnAfterWebPublish(ByVal pWeb As Web, Success As Boolean)
If Success = True Then
    pWeb.Properties.Add "Published", True
    pWeb.Properties.ApplyChanges
Else: MsgBox "There was a problem publishing your " & pWeb & " web."
End If
End Sub


OnBeforePageSave Event

Occurs before a page is saved.

Syntax

Private Sub Application_OnBeforePageSave(pPage As PageWindow, _

SaveAsUI As Boolean, Cancel As Boolean)

pPage Required PageWindow. The specified PageWindow object.

SaveAsUI Required Boolean. True for the first time the page has been saved. If SaveAsUI is True then the user used the SaveAs dialog box to save the page; if SaveAsUI is False, then the user used the Save dialog box to save an existing file.

Cancel Required Boolean. Causes Microsoft FrontPage to abort the save when set to True. When Cancel is programmatically set to True, the user can abort the save process by clicking the Cancel button on the form. Default is False.

Remarks

The OnBeforePageSave event is associated with the Application object. When the user saves a page or closes FrontPage, the OnBeforePageSave event fires and executes the code that you specified within the event procedure.

Note If you set Cancel to True, the page won't be saved.


OnBeforePageSave Event Example

This example displays a message box before the page has been saved and displays the document title of the file for the page.

Note To run this example, you must have at least one open web and one open page within that web.

Create a form called frmLaunchEvents.frm and add two buttons, a button called cmdSave, and a button called cmdCancel. Add the following code to the Declarations section of a form code window.

Option Explicit
Private WithEvents eFPApplication As Application
Private pPage As PageWindow

Add the following code to the UserForm_Initialize section of the code window.

Private Sub UserForm_Initialize()
Set eFPApplication = New Application
End Sub

Add the following code to the cmdSave_Click section of the code window.

Private Sub cmdSave_Click()
Dim myPageWindow As PageWindow

Set myPageWindow = ActiveWeb.ActiveWebWindow.ActivePageWindow
myPageWindow.Save
End Sub

Add the following code to the cmdCancel_Click section of the code window.

Private Sub cmdCancel_Click()
'Hide the form.
frmLaunchEvents.Hide
Exit Sub
End Sub

Add the following code to the eFPApplication_OnBeforePageSave section of the code window.

Private Sub eFPApplication_OnBeforePageSave(ByVal pPage As _
    PageWindow, SaveAsUI As Boolean, Cancel As Boolean)
MsgBox "The following page will be saved: " & pPage.File.Name _
    & "will be saved with the title: " & pPage.Document.Title
End Sub


OnBeforeWebPublish Event

Occurs before a web is published.

Syntax

Private Sub Application_OnBeforeWebPublish(pWeb As Web, Destination As String, Cancel As Boolean)

pWeb Required Web. The specified Web object.

Destination Required String. The URL of the target location.

Cancel Required Boolean. Causes Microsoft FrontPage to abort the publish when set to True. When Cancel is programmatically set to True, the user can abort the save process by clicking the Cancel button on the form. Default is False.

Remarks

The OnBeforeWebPublish event is associated with the Application object. When the user publishes a web in Microsoft FrontPage, the OnBeforeWebPublish event fires and executes the code that you specified within the event procedure.


OnBeforeWebPublish Event Example

This example adds a copyright string to the index page of the web that's being published.

Note To run this example, you must have at least one open web. This example uses a web called Rogue Cellars. You can create a web called Rogue Cellars or you can substitute a web of your choice in the following code sample.

Create a form called frmLaunchEvents.frm and add two buttons, a button called cmdPublishWeb, and a button called cmdCancel. Add the following code to the Declarations section of a form code window.

Option Explicit
Private WithEvents eFPApplication As Application
Private pPage As PageWindow

Add the following code to the UserForm_Initialize section of the code window.

Private Sub UserForm_Initialize()
Set eFPApplication = New Application
End Sub

Add the following code to the cmdPublishWeb_Click section of the code window.

Private Sub cmdPublishWeb_Click()
ActiveWeb.Publish "C:\My Documents\My Webs\Rogue Cellars"
End Sub

Add the following code to the cmdCancel_Click section of the code window.

Private Sub cmdCancel_Click()
'Hide the form.
frmLaunchEvents.Hide
Exit Sub
End Sub

Add the following code to the eFPApplication_OnBeforeWebPublish section of the code window.

Private Sub eFPApplication_OnBeforeWebPublish(ByVal pWeb As Web)
Dim myCopyright As String
Dim myIndexFile As WebFile

myCopyright = "Copyright 1999 by Rogue Cellars"
Set myIndexFile = pWeb.RootFolder.Files("index.htm")
myIndexFile.Open
If myIndexFile.Application.ActiveDocument.body.outerText <> _
    myCopyright Then
    myIndexFile.Application.ActiveDocument.body.insertAdjacentText _
        "BeforeEnd", myCopyright
End If
ActivePageWindow.Close
End Sub


OnPageClose Event

Occurs when a page is closed.

Syntax

Private Sub Application_OnPageClose(pPage As PageWindow, Cancel As Boolean)

pPage Required PageWindow. The specified PageWindow object.

Cancel Required Boolean. Causes Microsoft FrontPage to abort the close when set to True. When Cancel is programmatically set to True, the user can abort the save process by clicking the Cancel button on the form. Default is False.

Remarks

The OnPageClose event is associated with the Application object. When the user closes a PageWindow object, the OnPageClose event fires and executes the code that you specified within the event procedure.


OnPageClose Event Example

This example checks if a page has been modified and saves the page if the IsDirty property is True before closing the page.

Note To run this example, you must have at least one open web and one open page within that web.

Create a form called frmLaunchEvents.frm and add two buttons, a button called cmdClosePage, and a button called cmdCancel. Add the following code to the Declarations section of a form code window.

Option Explicit
Private WithEvents eFPApplication As Application
Private pPage As PageWindow

Add the following code to the UserForm_Initialize section of the code window.

Private Sub UserForm_Initialize()
Set eFPApplication = New Application
End Sub

Add the following code to the cmdClosePage_Click section of the code window.

Private Sub cmdClosePage_Click()
ActivePageWindow.Close
End Sub

Add the following code to the cmdCancel_Click section of the code window.

Private Sub cmdCancel_Click()
'Hide the form.
frmLaunchEvents.Hide
Exit Sub
End Sub

Add the following code to the eFPApplication_OnPageClose section of the code window.

Private Sub eFPApplication_OnPageClose(ByVal pPage As _
    PageWindow, Cancel As Boolean)
If pPage.IsDirty = True Then pPage.Save
End Sub


OnPageNew Event

Occurs when a new page is created.

Syntax

Private Sub Application_OnPageNew(pPage As PageWindow)

pPage Required PageWindow. A PageWindow object.

Remarks

When the user creates a new page within a frameset, the OnPageNew event is only fired once for Frames pages—when the page containing the frameset tags is opened. Then FrontPage executes the code that you specified within the event procedure.

Note The OnPageNew event only fires for the default frameset, even if there are more frames on the page. This event only fires if FrontPage is in Page view. If FrontPage is in any other view, the OnPageNew event won't fire.


OnPageNew Event Example

This example applies a theme to a new page.

Note To run this example, you must have at least one open web. This example uses Rogue Cellars as the specified web and Zinfandel.htm as the specified page. You can create a web and page using these names or you can substitute a web and page of your choice.

Create a form called frmLaunchEvents.frm and add two buttons, a button called cmdAddPage, and a button called cmdCancel. Add the following code to the Declarations section of a form code window.

Option Explicit
Private WithEvents eFPApplication As Application
Private pPage As PageWindow

Add the following code to the UserForm_Initialize section of the code window.

Private Sub UserForm_Initialize()
Set eFPApplication = New Application
End Sub

Add the following code to the cmdAddPage_Click section of the code window. This code adds a file to the PageWindows collection and opens it.

Private Sub cmdAddPage_Click()
Dim myPageWindows As PageWindows
Dim myFile As String

Set myPageWindows = ActiveWeb.ActiveWebWindow.PageWindows
myFile = _
    "file:///C:/My Documents/My Webs/Rogue Cellars/Zinfandel.htm"
myPageWindows.Add (myFile)
End Sub

Add the following code to the cmdCancel_Click section of the code window.

Private Sub cmdCancel_Click()
'Hide the form.
frmLaunchEvents.Hide
Exit Sub
End Sub

Add the following code to the eFPApplication_OnPageNew section of the code window.

Private Sub eFPApplication_OnPageNew(ByVal pPage As _
    PageWindow)
pPage.ApplyTheme ("artsy")
End Sub


OnPageOpen Event

Occurs when a page is opened.

Syntax

Private Sub Application_OnPageOpen(pPage As PageWindow)

pPage Required PageWindow. A PageWindow object.

Remarks

The OnPageOpen event is associated with the Application object. When the user opens a page, Microsoft FrontPage opens the frameset for the page and fires the OnPageOpen event for the default frameset. Then FrontPage executes the code that you specified within the event procedure.

Note The OnPageOpen event only fires for the default frameset, even if there are more frames on the page.The OnPageOpen event only fires if the page is not open.


OnPageOpen Event Example

This example changes the title of the FPHTMLDocument object, when the document is opened in a PageWindow object.

Note To run this example, you must have at least one open web. This example uses Rogue Cellars as the specified web and Zinfandel.htm as the specified page. You can create a web and page using these names or you can substitute a web and page of your choice.

Create a form called frmLaunchEvents.frm and add two buttons, a button called cmdOpenPage, and a button called cmdCancel. Add the following code to the Declarations section of a form code window.

Option Explicit
Private WithEvents eFPApplication As Application

Add the following code to the UserForm_Initialize section of the code window.

Private Sub UserForm_Initialize()
Set eFPApplication = New Application
End Sub

Add the following code to the cmdAddPage_Click section of the code window.

Private Sub cmdAddPage_Click()
Dim myPageWindows As PageWindows
Dim myFile As String

Set myPageWindows = ActiveWeb.ActiveWebWindow.PageWindows
myFile = _
    "file:///C:/My Documents/My Webs/Rogue Cellars/Zinfandel.htm"
myPageWindows.Add (myFile)
End Sub

Add the following code to the cmdCancel_Click section of the code window.

Private Sub cmdCancel_Click()
'Hide the form.
frmLaunchEvents.Hide
Exit Sub
End Sub

Add the following code to the eFPApplication_OnPageOpen section of the code window.

Private Sub eFPApplication_OnPageOpen(ByVal pPage As _
    PageWindow)
Dim myDoc As FPHTMLDocument

Set myDoc = pPage.ActiveDocument

myDoc.Title = "Rogue Cellars Home Page"
End Sub


OnWebClose Event

Occurs when a web is closed.

Syntax

Private Sub Application_OnWebClose(pWeb As Web, Cancel As Boolean)

pWeb Required Web. A Web object.

Cancel Required Boolean. True if the closing process was cancelled through the user interface, or if Cancel was set to True. Default is False.

Remarks

The OnWebClose event is associated with the Application object. When you close a web, the OnWebClose event fires and executes the code that you specified within the event procedure.


OnWebClose Event Example

This example iterates through the open pages and, if necessary, saves them before the web is closed.

Note To run this example, you must have at least one open web and one open page within that web. This example uses Rogue Cellars as the specified web. You can create a web called Rogue Cellars or substitute a web of your choice.

Create a form called frmLaunchEvents.frm and add two buttons, a button called cmdCloseWeb, and a button called cmdCancel. Add the following code to the Declarations section of a form code window.

Option Explicit
Private WithEvents eFPApplication As Application
Private pPage As PageWindow

Add the following code to the UserForm_Initialize section of the code window.

Private Sub UserForm_Initialize()
Set eFPApplication = New Application
End Sub

Add the following code to the cmdCloseWeb_Click section of the code window. This code sample closes the specified web.

Private Sub cmdCloseWeb_Click()
Webs("file:///C:/My Documents/My Webs/Rogue Cellars").Close
End Sub

Add the following code to the cmdCancel_Click section of the code window.

Private Sub cmdCancel_Click()
'Hide the form.
frmLaunchEvents.Hide
Exit Sub
End Sub

Add the following code to the eFPApplication_OnWebClose section of the code window. This code sample iterates through the open pages and saves them if they have been modified.

Private Sub eFPApplication_OnWebClose(ByVal pWeb As Web, _
    Cancel As Boolean)
Dim myPageWindows As PageWindows
Dim myPageWindow As PageWindow

Set myPageWindows = pWeb.ActiveWebWindow.PageWindows

For Each myPageWindow In myPageWindows
    If myPageWindow.IsDirty = True Then myPageWindow.Save
Next
End Sub


OnWebNew Event

Occurs when a new web is created.

Syntax

Private Sub Application_OnWebNew(pWeb As Web)

pWeb Required Web. A Web object.

Remarks

The OnWebNew event is associated with the Application object. When the user creates a new web in Microsoft FrontPage, the OnWebNew event fires and executes the code that you specified within the event procedure.


OnWebNew Event Example

This example creates a temporary web and adds and opens a new file.

Create a form called frmLaunchEvents.frm and add two buttons, a button called cmdCreateWeb, and a button called cmdCancel. Add the following code to the Declarations section of a form code window.

Option Explicit
Private WithEvents eFPApplication As Application
Private pPage As PageWindow

Add the following code to the UserForm_Initialize section of the code window.

Private Sub UserForm_Initialize()
Set eFPApplication = New Application
End Sub

Add the following code to the cmdCreateWeb_Click section of the code window.

Private Sub cmdCreateWeb_Click()
Webs.Add ("file:///C:/My Documents/My Webs/TempWeb")
End Sub

Add the following code to the cmdCancel_Click section of the code window.

Private Sub cmdCancel_Click()
'Hide the form.
frmLaunchEvents.Hide
Exit Sub
End Sub

Add the following code to the eFPApplication_OnWebNew section of the code window.

Private Sub eFPApplication_OnWebNew(ByVal pWeb As Web)
Dim myFile As WebFile

Set myFile = pWeb.RootFolder.Files.Add("index.htm")
myFile.Open
End Sub


OnWebOpen Event

Occurs when a web is opened.

Syntax

Private Sub Application_OnWebOpen(pWeb As Web)

pWeb Required Web. A Web object.

Remarks

The OnWebOpen event is associated with the Application object. When the user opens a web in Microsoft FrontPage, the OnWebOpen event fires and executes the code that you specified within the event procedure.


OnWebOpen Event Example

This example opens the index.htm file when a web is opened.

Note This example uses Rogue Cellars as the specified web to be opened. You can create a web called Rogue Cellars or you can substitute a web of your choice.

Create a form called frmLaunchEvents.frm and add two buttons, a button called cmdOpenWeb, and a button called cmdCancel. Add the following code to the Declarations section of a form code window.

Option Explicit
Private WithEvents eFPApplication As Application
Private pPage As PageWindow

Add the following code to the UserForm_Initialize section of the code window.

Private Sub UserForm_Initialize()
Set eFPApplication = New Application
End Sub

Add the following code to the cmdOpenWeb_Click section of the code window.

Private Sub cmdOpenWeb_Click()
webs.Open ("file:///C:/My Documents/My Webs/Rogue Cellars")
End Sub

Add the following code to the cmdCancel_Click section of the code window.

Private Sub cmdCancel_Click()
'Hide the form.
frmLaunchEvents.Hide
Exit Sub
End Sub

Add the following code to the eFPApplication_OnWebOpen section of the code window.

Private Sub eFPApplication_OnWebOpen(ByVal pWeb As Web)
Dim myFile As WebFile

Set myFile = pWeb.RootFolder.Files.Add("index.htm")
myFile.Open
End Sub


Activate Method

Activates the specified PageWindow, Web, or WebWindow object. With multiple objects open, you can use the Activate method to work with a specific PageWindow, Web, or WebWindow object.

Syntax

expression.Activate

expression An expression that returns a PageWindow, Web, or WebWindow object.

Return Type

Void

Remarks

The Activate method has no effect on a windowless PageWindow.


Activate Method Example

This statement activates the home page for the Adventure Works Web site.

If myWeb.Url = "C:\My Webs\Adventure Works" Then myWeb.Activate


Add Method

Adds a new item to the specified collection. Items in a collection are automatically indexed starting with zero.

Note Microsoft Office indexes collection items starting with one. For example, FrontPage provides an accessor for the CommandBars collection that is available for all Office products. When using the CommandBars property to return the CommandBars object, indexing starts at one because this property is accessing an Office object.

FrontPage provides the Add method objects as listed in the following table. For further information on the Add method objects shown, click the name of that object in the table.

Add Method Collection | Description
NavigationNodes | Adds a new NavigationNode object to the list of available items in the NavigationNodes collection.
PageWindows | Adds a new PageWindow object to the list of available items in the PageWindows collection.
Properties | Adds a new Property object to the list of available items in the Properties collection.
WebFiles | Adds a new WebFile object to the list of available items in the WebFiles collection.
WebFolders | Adds a new WebFolder object to the list of available items in the WebFolders collection.
Webs | Adds a new Web object to the list of available items in the Webs collection.

Remarks

Web administrators can set permissions that affect the use of the Add method. There are three categories of permissions: browsers, authors, and administrators. People who only browse the web are generally restricted from adding files to the WebFiles and PageWindows collections.


Add Method (NavigationNodes Collection)

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.

Syntax

expression.Add(Url As String, NodeLabel As String, uModType As FpStructModType, [LeftSibling])

expression An expression that returns a NavigationNodes collection object.

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.

uModType Required FpStructModType. The possible settings for the node are shown in the following table.

Argument | Value | Description
FpStructBaseOnSibling | 0 | Use this setting if you want to add a new node to the right of the node designated in the left sibling argument.
FpStructLeftMostChild | 1 | The leftmost node in the current navigation structure.
FpStructRightMostChild | 2 | 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.


Add Method (NavigationNodes Collection) Example

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 called "C:\My Documents\My Webs\Rogue Cellars" (for a server running on Microsoft Windows) or "C:\WINNT\Profiles\logon alias\Personal\My Webs\Rogue Cellars" (for a server running on Windows NT) and a FrontPage-based file called footnote.htm. Or, you may substitute an alternative web URL or file.

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

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


Add Method (PageWindows Collection)

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.


Add Method (PageWindows Collection) Example

This example adds the Inventory page for Rogue Cellars 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, refer to the description in the Add method.

Note To run this example, you must have a web called "C:\My Documents\My Webs\Rogue Cellars" (for a server running on Microsoft Windows) or "C:\WINNT\Profiles\logon alias\Personal\My Webs\Rogue Cellars" (for a server running on Windows NT) and a file called Inventory.htm. Or, you may substitute an alternative web URL or file.

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

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

myPageWindows.Add (myPage)
End Sub


Add Method (Properties Collection)

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

Syntax

expression.Add(PropertyKey As String, PropertyValue)

expression 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.

PropertyValue Required Variant. The value of the property.

Remarks

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


Add Method (Properties Collection) Example

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 called "C:\My Documents\My Webs\Rogue Cellars\Zinfandel.htm" (for a server running on Microsoft Windows) or "C:\WINNT\Profiles\logon alias\Personal\My Webs\Rogue Cellars\Zinfandel.htm" (for a server running on Windows NT) and a FrontPage-based file called footnote.htm. Or, you may substitute an alternative web URL or file.

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

myCopyright = "Copyright 1999 by Rogue Cellars"
Set myWeb = Webs.Open("C:\My Webs\Rogue Cellers")
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


Add Method (WebFiles Collection)

Adds a new WebFile object to the list of available items in the WebFiles collection. A WebFile object 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.

Syntax

expression.Add(FileUrl As String)

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

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.

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.


Add Method (WebFiles Collection) Example

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")


Add Method (WebFolders Collection)

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

Syntax

expression.Add(FolderUrl As String)

expression An expression that returns a WebFolders collection object.

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.


Add Method (WebFolders Collection) Example

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

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


Add Method (Webs Collection)

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

Syntax

expression.Add(WebUrl As String, [UserName], [Password])

expression 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.


Add Method (Webs Collection) Example

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

Webs.Add ("C:\My Documents\My Webs\Rogue Cellars")


ApplyChanges Method

Apply changes to the specified object. Changes to a property of a Web, WebFile, or WebFolder object are not applied until you use the ApplyChanges method for the specified object.

Syntax

expression.ApplyChanges

expression An expression that returns a Properties object.

Return Type

Void


ApplyChanges Method Example

This example changes the value of the vti_title property for a file called Zinfandel.htm and applies the change.

Private Sub ChangeProperties()
Dim myProperties As Properties

Set myProperties = _
    ActiveWeb.RootFolder.Files("Zinfandel.htm").Properties
myProperties("vti_title") = "Rogue Cellars Wine List"
myProperties.ApplyChanges
End Sub


ApplyNavigationStructure Method

Apply the navigation structure to the specific object.

Syntax

expression.ApplyNavigationStructure

expression An expression that returns a Web object.

Return Type

Void

Remarks

There are two details to keep in mind when programmatically creating files and navigation nodes:

  • Navigation labels cannot be empty.

  • Changes to the navigation structure can be lost if you don't apply the navigation structure before starting operations that affect the content of the web such as moving file or folders, and adding files or folders.


ApplyNavigationStructure Method Example

This example adds a navigation node as the rightmost child node and then applies the changes to the navigation structure.

Private Sub AddNewNavNode()
Dim myWeb As Web
Dim myChildNodes As NavigationNodes
Dim myNewNavNode As NavigationNode

Set myWeb = ActiveWeb
Set myChildNodes = _
 myWeb.RootFolder.Files(1).NavigationNode.Children

myNewNavNode = _
 myChildNodes.Add(myWeb.Url & "Sale.htm", "Sale", _
    fpStructRightmostChild)
myWeb.ApplyNavigationStructure
End Sub


ApplyTheme Method

Applies the value contained in the ThemeName argument to the property named in the ThemeProperties argument. For example, a theme can be applied to WebFile, PageWindow, or Web objects in a Microsoft FrontPage-based web.

Syntax

expression.ApplyTheme(ThemeName As String, ThemeProperties As FpThemeProperties)

expression An expression that returns an FrontPage object.

ThemeName Required String. A string that contains the name of the theme that you want to apply to a file. Can be one of the following ThemeName constants.

artsy | boldstri | indust | sumipntg
blank | capsules | ricepapr |
blends | citrus | rmnsque |
blueprnt | expeditn | strtedge |

ThemeProperties Required Long. The ThemeProperties argument takes the enumerated types shown in the following table.

Enumerated Type | Default Value
FpThemeActiveGraphics | &H10 or 16
FpThemeBackgroundImage | 1
FpThemeCSS | &H1000 or 4096
FpThemeDefaultSettings | &H1000000 or 16777216
FpThemeName | &H2000000 or 33554432
FpThemeNoBackgroundImage | 0
FpThemeNoCSS | 0
FpThemeNormalColors | 0
FpThemeNormalGraphics | 0
FpThemePropertiesAll | &H1111 or 4369
FpThemePropertiesNone | 0
FpThemeVividColors | &H100 or 256

Remarks

The following code applies the "Sumi Painting" theme to a file with active graphics.

Dim strTheme As String

strTheme = "sumipntg"
Call WebFile.ApplyTheme(strTheme, fpThemeUseActiveGraphics)

To change more than one Theme property when applying the theme, use the plus sign (+), as shown in the following example.

strTheme = "sumipntg"
WebFile.ApplyTheme(strTheme, _
fpThemeVividColors + fpThemeActiveGrphics)

This method is essentially the same one you'd use for applying a theme to a PageWindow or Web object.


ApplyTheme Method Example

This example contains a function, ApplyThemeToFilesInFolder, and a procedure that you can modify to apply any of the available themes. This example applies the "Artsy" theme to all files in a specified folder.

Note To run this example, copy the following code into a module in the Visual Basic Editor and run the ChangeToArtsy procedure.

Function ApplyThemeToFilesInFolder(myThemeName As String, _
    myFolderObject As WebFolder) As Boolean
Dim myFile As WebFile
Dim myTheme As Theme

On Error GoTo ERR

For Each myFile In myFolderObject.Files
Call myFile.ApplyTheme(myThemeName, fpThemePropertiesAll)
Next myFile

ApplyThemeToFilesInFolder = True
Exit Function

ERR:
MsgBox "An error occured: " & ERR.Description, vbCritical, "Error!"
ApplyThemeToFilesInFolder = False
Exit Function

End Function

Private Sub ChangeToArtsy()
ApplyThemeToFilesInFolder "artsy", ActiveWeb.RootFolder
End Sub


CancelRequests Method

Immediately cancels all requests to the Web object without saving.

Syntax

expression.CancelRequests

expression An expression that returns a Web object.

Return Type

Void


CancelRequests Method Example

The CancelRequests method can be used to stop a process that may be taking too long, may appear to be in an infinite loop, or that may be coming from a questionable source.

Private Sub CancelRequestsToWeb_Click()
Dim myWeb As Web

Set myWeb = ActiveWeb
myWeb.CancelRequests
End Sub


Checkin Method

Checks the specified WebFile object in to the source control project.

Note You must have a source control project in place before using this method. For information about source control projects, refer to Managing Source Control Projects.

Syntax

expression.Checkin(Comment, KeepCheckedout)

expression An expression that returns a WebFile object.

Comment Required String. A description string.

KeepCheckedout Optional Boolean. Keeps the file checked out. Default value is False.

Return Type

Void

Remarks

The KeepCheckedout argument provides the ability to have the file remain in a checkedout state while the user checks the file in to Microsoft Visual SourceSafe to record the changes. This does not apply to FrontPage Light Weight source control.


Checkin Method Example

The program in this example performs the following steps:

  • Checks out a file and puts the file in edit mode.

  • Adds a welcome message to the document.

  • Checks if the open page has been modified.

  • If the page has been modified, the page is saved.

  • Then the file is closed and checked into the existing source control project.

Note To run this example, you must have a source control project in place on a web with a file called "C:\My Documents\My Webs\Rogue Cellars\Zinfandel.htm" (for a server running on Microsoft Windows) or "C:\WINNT\Profiles\logon alias\Personal\My Webs\Rogue Cellars\Zinfandel.htm" (for a server running on Windows NT). Or, you may substitute a web and file of your choice.

Private Sub CheckinFile()
Dim myWeb As Web
Dim myFile As WebFile
Dim myPageWindow As PageWindow
Dim myWelcome As String

Set myWeb = Webs("C:/My Webs/Rogue Cellars")
myWelcome = "Welcome to my Web Site!"
Set myFile = myWeb.RootFolder.Files("Zinfandel.htm")
myFile.Checkout
Set myPageWindow = myFile.Edit(fpPageViewNormal)
With myPageWindow
    myPageWindow.Document.body.insertAdjacentText "BeforeEnd", _
        myWelcome
    If myPageWindow.IsDirty = True Then myPageWindow.Save
    .Close
End With
myFile.Checkin
End Sub


Checkout Method

Checks the specified WebFile object out to the source control project.

Note You must have a source control project in place before using this method. For information about source control projects, refer to Managing Source Control Projects.

Syntax

expression.Checkout(ForceCheckout)

expression An expression that returns a WebFile object.

ForceCheckout Optional Boolean. Forces a checkout, even if the file is already checked out. Default value is False.

Return Type

Void

Remarks

The ForceCheckout argument provides the administrator with the ability to force a checkout in cases where a file has been checked out by a user who is unavailable to check the file back in.


Checkout Method Example

The program in this example performs the following steps:

  • Checks out a file from an existing source control project and puts the file in edit mode.

  • Adds a welcome message to the document.

  • Checks if the open page has been modified.

  • If the page has been modified, the page is saved.

  • Then the file is closed and checked into the existing source control project.

Note To run this example, you must have a source control project in place on a web with a file called "C:\My Documents\My Webs\Rogue Cellars\Zinfandel.htm" (for a server running on Microsoft Windows) or "C:\WINNT\Profiles\logon alias\Personal\My Webs\Rogue Cellars\Zinfandel.htm" (for a server running on Windows NT). Or, you may substitute a web and file of your choice.

Private Sub CheckoutFile()
Dim myWeb As Web
Dim myFile As WebFile
Dim myPageWindow As PageWindow
Dim myWelcome As String

Set myWeb = Webs("C:/My Webs/Rogue Cellars")
myWelcome = "Welcome to my Web Site!"
Set myFile = myWeb.RootFolder.Files("Zinfandel.htm")
myFile.Checkout
Set myPageWindow = myFile.Edit(fpPageViewNormal)
With myPageWindow
    myPageWindow.Document.body.insertAdjacentText "BeforeEnd", _
        myWelcome
    If myPageWindow.IsDirty = True Then myPageWindow.Save
    .Close
End With
myFile.Checkin
End Sub


Close Method

Closes the specified object.

Syntax 1: Closes the specified PageWindow object.

Syntax 2: Closes the specified pages in the PageWindows collection, or, if null, closes all open pages in the PageWindows collection.

Syntax 3: Closes the specified WebWindow object.

Syntax 4: Closes the specified webs in the WebWindows collection.

Syntax 1

expression.Close([ForceSave As Boolean])

expression An expression that returns a PageWindow object.

ForceSave Optional Boolean. True forces the specified file to be saved before the Close method is completed. Default is False.

Return Type

Void

Syntax 2

expression.Close([Index],[ForceSave As Boolean])

expression An expression that returns an object from the PageWindows collection.

Index Optional Variant. Refers to an individual item in the PageWindows collection. Can be any number corresponding to an item in the collection, with the index starting at zero.

ForceSave Optional Boolean. True forces the specified file to be saved before the Close method is completed. Default is False.

Return Type

Void

Syntax 3

expression.Close()

expression An expression that returns a WebWindow object.

Return Type

Void

Syntax 4

expression.Close(Index)

expression An expression that returns an object in the WebWindows collection.

Index Optional Variant. Refers to an item in the WebWindows collection. Can be any number corresponding to an item in the collection, with the index starting at zero.

Return Type

Void

Remarks

The following examples illustrate how you use each type of syntax with the Close method.

Syntax 1: The PageWindow object provides an optional forced save argument, set in the following statement to True, so that before myPageWindow is closed, it will be saved.

myPageWindow.Close(True)

However, to close myPageWindow without forcing a save, remove the forced save argument from between the parentheses, as shown in the following statement, or set the argument to False.

myPageWindow.Close()
myPageWindow.Close(False)

Syntax 2: The PageWindows collection also provides the optional forced save argument along with an index to reference individual PageWindow objects. The following statement shows an individual page in the collection closed with a forced save.

myPageWindows.Close(2,True)

Note If the argument is null, as in the following statement, Microsoft FrontPage closes all open pages.

myPageWindows.Close()

Syntax 3: The WebWindow object uses a straightforward Close method. This method is useful when you want to analyze webs and don't need to work with individual pages in the web.

myWebWindow.Close

Syntax 4: The WebWindows collection provides a zero-based index to reference individual WebWindow objects. The following statement closes the second open WebWindow object.

myWebWindow.Close(1)

Note If the argument is null as in the following statement, Microsoft FrontPage closes all open web windows.

myPageWindows.Close()


Close Method Example

This example closes the fourth open page and calls the error handler to display a message if error 4198 results—that means the user clicked the Cancel button.

On Error GoTo errorHandler
PageWindows.Close(3,True)

errorHandler:
If Err=4198 Then MsgBox "PageWindow was not closed."


Copy Method

Copies the specified object to a designated URL. During the copy process you can choose to update hyperlinks or force a file overwrite if the specified object has the same name as the designated object.

Syntax

expression.Copy(DestinationUrl As String, UpdateLinks As Boolean, ForceOverwrite As Boolean)

expression An expression that returns a WebFile or WebFolder object.

DestinationUrl Required String. The target URL.

UpdateLinks Required Boolean. Specifies whether links are to be updated during the copy process. True to update links.

ForceOverwrite Required Boolean. Specifies whether to force a file overwrite when a file or folder is found with the same name. Set the argument to True to force a file overwrite.

Return Type

Void

Remarks

The Copy method only copies files or folders within the same web. You cannot copy across webs. However, you can use the SaveAs method for the PageWindow object to save a page that has its file currently located in one web to save the page to a file in another web. Or, you can use the Add method for the WebFile object to add a file that is currently located in one web to another web.


Copy Method Example

This example copies a file from the Rogue Cellars web folder to an Inventory folder within the same web.

Note To run this example, you must have a web called "C:\My Documents\My Webs\Rogue Cellars" (for a server running on Microsoft Windows) or "C:\WINNT\Profiles\logon alias\Personal\My Webs\Rogue Cellars" (for a server running on Windows NT).

Private Sub FileCopy()
Dim myFile As WebFile

Set myFile = ActiveWeb.RootFolder.Files("Zinfandel.htm")
myFile.Copy "C:\My Webs\Rogue Cellars\Inventory\Zinfandel.htm"
End Sub


Delete Method

Deletes the specified object. As opposed to removing an object (when using the RemoveWeb method) from a Microsoft FrontPage-based web. For example, in Navigation view in FrontPage, you can remove a page from a FrontPage-based Web site, but the page and its associated file still exist on the server or hard drive. When you use the Delete method to delete an object, that object ceases to exist. For more information on using the Delete method with other objects, click an item in the following table.

Object | Description
NavigationNodes | Deletes the specified navigation node from the list of available nodes in the NavigationNodes collection.
Properties | Deletes the specified property from the list of available properties in the Properties collection for the Web, WebFile, or WebFolder objects.
Web | Deletes the specified web
WebFile | Deletes the specified file from the web.
WebFiles | Deletes the specified file from the list of available files in the Files collection.
WebFolder | Deletes the specified folder from the web.
WebFolders | Deletes the specified folder from the list of available folders in the Folders collection.
Webs | Deletes the specified web from the list of available webs in the Webs collection.


Delete Method (NavigationNodes)

Deletes an individual navigation node from the list of available nodes in the NavigationNodes collection.

Syntax

expression.Delete(Index)

expression An expression that returns a NavigationNodes object.

Index Required Variant. Refers to an item in the navigation structure. Can be any number corresponding to an item in the navigation structure, with the index starting at zero.


Delete Method (NavigationNodes) Example

This example deletes the fourth navigation node of the second file in the active web.

Note You must apply the navigation structure to the web in order for the changes to be applied to the web.

Private Sub DeleteNavNode()
Dim myWeb As Web
Dim myChildNodes As NavigationNodes

Set myWeb = ActiveWeb
Set myChildNodes = _
    myWeb.RootFolder.WebFiles(1).NavigationNode.Children

Call myChildNodes.Delete(3)
myWeb.ApplyNavigationStructure
End Sub


Delete Method (Properties)

Deletes a property from the list of available properties in the Properties collection.

Syntax

expression.Delete(PropertyKey As String)

expression An expression that returns a Properties object.

PropertyKey Required. A string that represents the property name.


Delete Method (Properties) Example

This example deletes the SaleText property from the Sales.htm file.

Private Sub DeleteProperty()
Dim myFile As WebFile
Dim myProp As String

Set myFile = ActiveWeb.RootFolder.Files("Sales.htm")
myFile.Properties.Delete ("SaleText")
End Sub


Delete Method (Web)

Deletes a web from the list of available webs in the Webs collection.

Syntax

expression.Delete()

expression An expression that returns a Webs object.


Delete Method (WebFile)

Deletes the specified file from a web.

Syntax

expression.Delete()

expression An expression that returns a WebFile object.


Delete Method (WebFiles)

Deletes a task from the list of available tasks in the WebFiles collection.

Syntax

expression.Delete(Index)

expression An expression that returns a WebFiles object.

Index Required. Refers to an item in the WebFiles collection. Can be any number corresponding to an item in the collection, with the index starting at zero.


Delete Method (WebFiles) Example

This statement deletes a file in the active web.

Note To run this example, you must have a file called "C:\My Documents\My Webs\TempFile.htm" (for a server running on Microsoft Windows) or "C:\WINNT\Profiles\logon alias\Personal\My Webs\TempFile.htm" (for a server running on Windows NT). In either case, you may substitute an alternative web file.

ActiveWeb.RootFolder.Files.Delete "TempFile"


Delete Method (WebFile) Example

This example deletes a file from the active web.

Note To run this example, you must have a file called "C:\My Documents\My Webs\TempFile.htm" (for a server running on Microsoft Windows) or "C:\WINNT\Profiles\logon alias\Personal\My Webs\TempFile.htm" (for a server running on Windows NT). In either case, you may substitute an alternative web file.

Private Sub DeleteFile()
Dim myFile As WebFile

Set myFile = ActiveWeb.RootFolder.Files("TempFile")
myFile.Delete

End Sub


Delete Method (WebFolder)

Deletes the specified folder from a web.

Syntax

expression.Delete()

expression An expression that returns a WebFolder object.


Delete Method (WebFolders)

Deletes a folder or folders from the list of available folders in the WebFolders collection.

Syntax

expression.Delete(Index)

expression An expression that returns a WebFolders object.

Index Required. Refers to an item in the WebFolders collection. Can be any number corresponding to an item in the collection, with the index starting at zero.


Delete Method (WebFolders) Example

This statement deletes the second folder in the active web.

ActiveWeb.RootFolder.Folders.Delete(1)


Delete Method (WebFolder) Example

This example deletes a folder from the active web.

Note To run this example, you must have a file called "C:\My Documents\My Webs\TempFolder" (for a server running on Microsoft Windows) or "C:\WINNT\Profiles\logon alias\Personal\My Webs\TempFolder" (for a server running on Windows NT). In either case, you may substitute an alternative web folder.

Private Sub DeleteFolder()
Dim myFolder As WebFolder

Set myFolder = ActiveWeb.RootFolder.Folders("TempFolder")
myFolder.Delete

End Sub


Delete Method (Webs)

Deletes a web from the list of available webs in the Webs collection.

Syntax

expression.Delete(pvIndex)

expression An expression that returns a Webs object.

Index Required. Refers to an item in the Webs collection. Can be any number corresponding to an item in the collection, with the index starting at zero.


Delete Method (Webs) Example

This statement deletes the fourth web.

Webs.Delete(3)


Delete Method (Web) Example

This example deletes a temporary web called TempWeb.

Note To run this example, you must have a web called "C:\My Documents\My Webs\TempWeb" (for a server running on Microsoft Windows) or "C:\WINNT\Profiles\logon alias\Personal\My Webs\TempWeb" (for a server running on Windows NT). In either case, you may substitute an alternative web URL.

Private Sub DeleteWeb()
Dim myWeb As Web
Dim myTempWeb As Web
Dim myFolders As WebFolders
Dim myFolder As WebFolder
Dim myWebToDelete As String

Set myWeb = Webs.Open("C:\My Documents\My Webs")
Set myFolders = myWeb.RootFolder.Folders
myWebToDelete = "TempWeb"

For Each myFolder In myFolders
    If myFolder.IsWeb = True Then
        If myFolder.Name = myWebToDelete Then
            Set myTempWeb = Webs.Open(myFolder.Name)
            myTempWeb.Delete
        End If
    End If
Next
ActiveWebWindow.Close
End Sub


Edit Method

Opens FrontPage-compatible files into a PageWindow object. These files include file formats such as HTML, .css, or .asp. To open external files for modification with formats such as .gif, .txt, or files without any extensions, use the Open method.

Note HTML files without extensions will not open with the Edit method.

Syntax

expression.Edit([ViewMode As FpPageViewMode = fpPageViewDefault]) As PageWindow

expression An expression that returns a File object.

ViewMode Optional FpPageViewMode. Use to open a file for editing in a specific view mode. Default is fpPageViewDefault. Default for HTML pages is fpPageViewNormal. Default for style sheet pages is fpPageViewHTML.

Return Type

PageWindow

Remarks

FrontPage-based external files can only be edited in a PageWindow object.


Edit Method Example

This example shows how to use the Edit method to open a file for editing.

Note You must have a web open to run this program with a file called RedWines.htm in the web or you may substitute a file of your choice.

Private Sub ModifyFile()
Dim myFile As WebFile

Set myFile = ActiveWeb.RootFolder.Files("RedWines.htm")

myFile.Edit
End Sub


LocateFile Method

Returns the specified WebFile object.

Syntax

expression.WebFile(String)

expression An expression that returns a Web object.

String Required LocateFile. Default value is the file portion of the URL.

Return Type

String


LocateFile Method Example

This example locates a file in the root directory of the web and puts the file in edit mode.

Note You must have a web open and a file called Zinfandel.htm or, you may substitute a file of your choice.

Private Sub LocateAFile()
Dim myFile As WebFile

Set myFile = Webs(0).LocateFile("Zinfandel.htm")
myFile.Edit
End Sub

In most cases, you would probably use the entire URL for the String argument of the LocateFile method. For example, a file may be several levels deep in the folder hierarchy, such as C:/My Documents/My Webs/Rogue Cellars/Inventory/First_Qtr.htm—and you want to locate First_Qtr.htm. Anytime a folder exists in a level deeper than the root directory of the web, use the entire URL as shown in the following example.

Private Sub GetFile()
Dim myFile As String
Dim myFileFound As WebFile

myFile = _
    "C:/My Documents/My Webs/Rogue Cellars/Inventory/First_Qtr.htm"

Set myFileFound = _
    Webs(0).LocateFile(myFile)
End Sub

However, there is a shortcut. For example, if you want to locate a file in an images folder that resides in the root directory of the web, you can use a web relative address by using a forward slash followed by the subfolder and file name as shown in the following statement.

Set myFileFound = _
    Webs(0).LocateFile("images/JPG/myJPGFileList.htm")

Note You cannot substitute a backslash in a web relative address.


LocateFolder Method

Returns the specified WebFolder object.

Syntax

expression.WebFolder(String)

expression An expression that returns a Web object.

String Required LocateFolder. Default value is the folder portion of the URL.

Return Type

String


LocateFolder Method Example

This example locates a folder in the root directory of a web.

Note You must have a web open for all of these examples.

Private Sub LocateAFolder()
Dim myFolderFound As WebFolder

Set myFolderFound = Webs(0).LocateFolder("images")
End Sub

In most cases, you would probably use the entire URL for the String argument of the LocateFolder method. For example, a folder may be several levels deep in the folder hierarchy, such as C:/My Documents/My Webs/Rogue Cellars/Inventory/First_Quarter—and you want to locate First_Quarter. Anytime a folder exists in a level deeper than the root directory of the web, use the entire URL as shown in the following example.

Private Sub GetFolder()
Dim myFolder As String
Dim myFolderFound As WebFolder

myFolder = _
    "C:/My Documents/My Webs/Rogue Cellars/Inventory/First_Quarter"

Set myFolderFound = _
    Webs(0).LocateFolder(myFolder)
End Sub

However, there is a shortcut. For example, if you want to locate an images folder that resides in the root directory of the web, you can use a web relative address by using a forward slash followed by the subfolder name as shown in the following statement.

Set myFolderFound = Webs(0).LocateFolder("images/JPG")

Note You cannot substitute a backslash in a web relative address.


LocatePage Method

Returns a PageWindow object for the specified object.

Syntax

expression.PageWindow(String, ViewMode)

expression An expression that returns an Application or Web object.

String Required LocatePage. A string that represents the document or file portion of the entire URL. This can be any absolute URL, such as "http://web server/document", "http://web server/file", or "file://file system/document" or "file://file system/file" for disk-based webs. Default value is the file portion of the URL.

Note The terms "document" and "file" refer to two different things. A document is an HTML file that can be read by FrontPage, while a file can be any type of file, local or external, and is not necessarily FrontPage-based.

ViewMode Optional FpPageViewMode. Default value is fpPageViewDefault. For more information, and a table for FpPageViewMode constants, see the ViewMode property.

Return Type

PageWindow


LocatePage Method Example

This example locates a page in the root web and a subweb.

Note You must have the page that you specify in the procedure open to use this method. To run this program, you can create a page called Zinfandel.htm or substitute a page of your own choice. You must have a copy of the page in the root web and a copy of it in a subweb.

Private Sub LocatePages()
Dim myRootPage As PageWindow
Dim myWebPage As PageWindow

Set myRootPage = _
    Application.LocatePage("Zinfandel.htm", fpPageViewNormal)
Set myWebPage = _
    Webs(1).LocatePage("Zinfandel.htm", fpPageViewNormal)
End Sub


MakeAbs Method

Changes the Application object to an absolute object rather than a relative object. For more information on absolute and relative URLs, refer to Understanding Absolute and Relative URL Addressing

Syntax

expression.MakeAbs(UrlBase, Url)

expression An expression that returns a Application object.

UrlBase Required Variant. A base URL. Can be one of the following, a string, or an object of type Web, WebFolder, WebFile, NavvigationNode, or IHTMLDocuemnt2.

Url Required String. A string that contains the entire URL for the web. This can be any URL for a web, such as http://web server/folder or file://file system/folder for disk-based webs.

Return Type

String


MakeAbs Method Example

This example changes a relative URL to an absolute URL.

Note To run this example, you must have a web and a file called "C:\My Documents\My Webs\Rogue Cellars\Zinfandel.htm" (for a server running on Microsoft Windows) or "C:\WINNT\Profiles\logon alias\Personal\My Webs\Rogue Cellars\Zinfandel.htm" (for a server running on Windows NT). In either case, you may substitute an alternative web URL or file.

Private Sub MakeURLAbsolute()
Dim myBaseURL As Web
Dim myAbsAddress As String
Dim myLocalUrl As String

myBaseURL = Webs.Open("C:\My Webs")
myLocalUrl = "Zinfandel.htm"

myAbsAddress = MakeAbs(myBaseURL, myLocalUrl)
End Sub


MakeRel Method

Changes the Application object to a relative object rather than an absolute object. For more information on absolute and relative URLs, refer to Understanding Absolute and Relative URL Addressing

Syntax

expression.MakeRel(UrlBase, Url)

expression An expression that returns an Application object.

UrlBase Required Variant. A base URL. Can be one of the following, a string, or an object of type Web, WebFolder, WebFile, NavvigationNode, or IHTMLDocuemnt2.

Url Required String. A string that contains the entire URL. This can be any URL for a web, such as http://web server/folder or file://file system/folder for disk-based webs.

Return Type

String


MakeRel Method Example

This example changes an absolute URL to a relative URL, adds a hyperlink to the active document using the relative URL, and then saves the changes to the active page window.

Note To run this example, you must have a web called "C:\My Documents\My Webs\Rogue Cellars" (for a server running on Microsoft Windows) or "C:\WINNT\Profiles\logon alias\Personal\My Webs\Rogue Cellars" (for a server running on Windows NT). You must also have two files, one called "Zinfandel.htm" and the other called "index.htm", which has an absolute URL (the default state). Or, you may substitute an alternative web URL and substitute alternative file names.

Private Sub MakeURLRelative()
Dim myFile As WebFile
Dim myFile2 As WebFile
Dim myBaseURL As Web
Dim myDoc As FPHTMLDocument
Dim myRelAddress As String
Dim myRelAddress2 As String

Set myBaseURL = Webs.Open("C:\My Documents\My Webs\Rogue Cellars")
Set myFile = myBaseURL.RootFolder.Files("Zinfandel.htm")
Set myFile2 = myBaseURL.RootFolder.Files("index.htm")
Set myDoc = myFile.Edit (fpPageViewNormal).Document

myRelAddress = MakeRel(myBaseURL, myFile2.Url)
myRelAddress2 = """" & myRelAddress & """"
Call myDoc.body.insertAdjacentHTML("BeforeEnd", "<a href=" _
    & myRelAddress2 & ">" & myRelAddress & "</a>")
ActivePageWindow.Save
End Sub


MakeWeb Method

Creates a new web from an existing folder. To create a new web without first creating a folder, see the Add method.

Syntax

expression.MakeWeb(UserName, Password)

expression An expression that returns a WebFolder object.

UserName Optional String. The logon name of the user. You can use this option to create a default username for the web.

Password Optional String. The password of the user. You can use this option to create a default password for the web.

Return Type

Void


MakeWeb Method Example

This example creates a new web from the existing Distributors folder. (The Distributors folder is a folder in the Rogue Cellars web.)

Private Sub MakeWeb()
Dim myWeb As Web
Dim myFolder As WebFolder

Set myWeb = Webs("C:\My Webs\Rogue Cellars")
myWeb.Activate
Set myFolder = Active.RootFolder.Folders("Distributors")
myFolder.MakeWeb
End Sub


Move Method

Moves the specified object to a designated location, which can be either a URL or a navigation node. During the move process for a URL location, you can choose to update hyperlinks or force a file overwrite if the specified object has the same name as the designated object.

Syntax 1: Moves the specified object from its current location to a designated URL.

Syntax 2: Moves a navigation node from one location to another in the navigation structure.

Syntax 1

expression.Move(DestinationUrl As String, UpdateLinks As Boolean, ForceOverwrite As Boolean)

expression An expression that returns a File or Folder object.

DestinationUrl Required String. The target URL, such as "C:\My Documents\My Webs\Adventure Works".

UpdateLinks Required Long. Designate True if links are to be updated during the move process. Default is False.

ForceOverwrite Required Long. Designate True if the object should be overwritten when a duplicate object is encountered. Default is False.

Return Type

Void

Syntax 2

expression.Move(NodeCollection As NavigationNodes, [NewLeftSibling]) As Object)

expression An expression that returns a NavigationNode object.

NodeCollection Required NavigationNodes. The target navigation collection.

NewLeftSibling Optional Object. The navigation node that will be the left sibling of the new node in the navigation structure. If it is not specified, the node will be moved to the rightmost end of the NodeCollection.

Return Type

NavigationNode (the node after it has been moved)


Move Method Example

This example includes code for both types of syntax.

Syntax 1: The following statement moves a file from one position in the file structure to another .

myFile.Move("C:\My Documents\My Webs\Adventure Works\Images", _
    True, False)

Syntax 2: The following example moves a node from the fifth position in the navigation structure to the fourth position in the navigation structure by designating the third node as the new left sibling.

Private Sub MoveNavNode()
Dim myNodes As NavigationNodes
Dim myNode As NavigationNode

Set myNodes = ActiveWeb.RootNavigationNode.Children
Set myNode = myNodes(4)

myNode.Move(myNodes, myNodes(2))
ActiveWeb.ApplyNavigationStructure
End Sub


Open Method

Opens the specified object.

Syntax 1: Opens the specified WebFile object.

Syntax 2: Opens the specified Web object.

Syntax 1

expression.Open

expression An expression that returns a WebFile object.

Return Type

Void

Syntax 2

expression.Open(szWebUrl As String, [UserName As String], [Password As String])

expression An expression that returns the Webs collection.

szWebUrl As String Required String. The base URL of the web, such as "C:\My Webs". This can be any absolute URL, such as "http://web server" or "file://file system" for disk-based webs.

UserName Optional String. The logon name of the user.

Password As String Optional String. A designated string of characters to validate access to the specified web.

Return Type

Web


Open Method Example

This example opens the Rogue Cellars web and the Oktoberfest Sale file, and performs the following tasks:

  • Adds text to the file by creating a property to hold the text

  • Accesses the Page object model using the ActiveDocument property and the insertAdjacentText method

  • Adds text to the page by substituting mySaleProp for the text parameter in the insertAdjacentText method

  • Closes Microsoft FrontPage

Note To run this example, you must have a web called "C:\My Documents\My Webs\Rogue Cellars" (for a server running on Microsoft Windows) or "C:\WINNT\Profiles\logon alias\Personal\My Webs\Rogue Cellars" (for a server running on Windows NT), or you may substitute an alternative web URL and file.

Private Sub AddSaleText()
Dim myWeb As Web
Dim myFile As WebFile
Dim mySaleProp As String
Dim mySaleText As String

mySaleText = "Vintage Wines for Oktoberfest Sale!!!"
Set myWeb = Webs.Open("C:\My Documents\My Webs\Rogue Cellars")
Set myFile = ActiveWeb.RootFolder.Files("Sale.htm")

myFile.Properties.Add "SaleText", mySaleText
mySaleProp = myFile.Properties("SaleText")
myFile.Open
ActiveDocument.body.insertAdjacentText "BeforeEnd", mySaleProp
WebWindows.Close
End Sub


Publish Method

Publishes a web to a Web server, whether on a server running Microsoft Internet Information Services (IIS) or on a Personal Web Server.

Syntax

expression.Publish(DestinationUrl As String, [PublishFlags As FpWebPublishFlags], [UserName As String],[Password As String])

expression An expression that returns a Web object.

DestinationUrl Required String. A string that contains the entire target URL for the web, such as “http://wwwroot/Adventure Works”. This can be any URL for a web, such as http://web server/folder or file://file system/folder for disk-based webs.

PublishFlags Required Long. Publishing flag constants are enumerated as shown in the following table.

Constant | Value
FpPublishNone | 0
FpPublishIncremental | 1
FpPublishAddToExistingWeb | 2
FpPublishCopySubwebs | 4

UserName Optional Variant. The name of the user who is publishing the web.

Password Optional Variant. The password of the user.

Return Type

Void


Publish Method Example

This example publishes the active web.

Note If the web you are publishing to is an existing web, you must use the argument fpPublishAddToExistingWeb, otherwise your web won't be published. If the web you are publishing to doesn't exist, don't use the fpPublishAddToExistingWeb argument because you're web won't be published.

Private Sub PublishMyWeb()
Dim myWeb As Web
Dim myBaseURL As String
Dim myPublishParam As FpWebPublishFlags

Set myWeb = Application.ActiveWeb
myBaseURL = "http://www.Adventure-Works.com"
myPublishParam = fpPublishAddToExistingWeb

myWeb.Publish(myBaseURL, myPublishParam)
End Sub


Quit Method

Quits the application. This method does not save any changes that have not been previously saved using the Save or SaveAs commands, but immediately exits the active application.

Syntax

expression.Quit

expression An expression that returns an Application object.

Return Type

Void


Quit Method Example

This example quits the application without saving any changes that were made since the previous Save or SaveAs commands were executed.

Private Sub QuitApp()
    Application.Quit
End Sub


RecalcHyperlinks Method

Recalculates all meta data on the server for this web. This operation will rebuild FrontPage’s knowledge of all hyperlinks, titles for web pages, themes on pages, and so on.

Note This operation may take a long time to complete depending on the amount of meta data on the server.

Syntax

expression.RecalcHyperlinks

expression An expression that returns a Web object.

Return Type

Void


RecalcHyperlinks Method Example

This example recalculates the hyperlinks for the active web.

Private Sub RecalcLinks()
Dim myWeb As Web

Set myWeb = Application.ActiveWeb

myWeb.RecalcHyperlinks
End Sub


Refresh Method

Refreshes the specified object.

Syntax 1: Refreshes the specified PageWindow object with an option to save changes.

Syntax 2: Refreshes the specified Web object.

Syntax 1

expression.Refresh([SaveChanges As Boolean][FetchAll])

expression An expression that returns a PageWindow object.

SaveChanges Optional Boolean. True to save changes.

FetchAll Optional Boolean. True to retrieve all information for all documents regardless of view. When set to False this argument retrieves only the information necessary to support the current view. However, if Reports or Hyperlink view is open, False refreshes all documents. Default is False.

Return Type

Void

Syntax 2

expression.Refresh

expression An expression that returns a Web object.

Return Type

Void


Refresh Method Example

The following statements refresh the active page window and the first page window of the first web.

ActivePageWindow.Refresh
WebWindows(0).PageWindows(0).Refresh

you can use the following statement to save any changes you may have made to the page.

ActivePageWindow.Refresh(True)

You can use the following statements to refresh the active web and the first web.

ActiveWeb.Refresh
Webs(0).Refresh


RemoveWeb Method

Removes the Web object from the specified WebFolder object.

Syntax

expression.RemoveWeb([UserName As String], [Password As String])

expression An expression that returns a WebFolder object.

UserName Optional String. The logon name of the user.

Password Optional String. The password of the user.

Return Type

Void

Remarks

The RemoveWeb method is the complement of the MakeWeb method. Just as the MakeWeb method creates the meta data for the web from a folder, the RemoveWeb method removes the meta data for the web from a folder, but the folder remains intact. This is different from the Delete method for the Web object, where the entire contents of the specified web are removed.


RemoveWeb Method Example

This example removes a web from a folder. The folder and its contents remain intact, but the folder is no longer a web.

Note You must have the web that contains the folder open.

Private Sub WebRemove()
Dim myFolders As WebFolders
Dim myFolder As WebFolder

Set myWebFolders = Webs(0).RootFolder.Folders

For Each myFolder In myFolders
 If myFolder.Name = "TempWeb" Then
  myFolder.RemoveWeb
  Exit For
 End If
Next
End Sub


Run Method

Runs the designated Microsoft Visual Basic macro. You can use the Run method to execute a specified procedure in Microsoft FrontPage. You can also use the Run method from within the procedure of an ActiveX control that carries out instructions that query or modify a FrontPage-based web.

Note: You cannot pass parameters to a procedure using the Run method. Use the Call statement to pass parameters to a procedure.

Syntax

expression.Run(MacroName As String)

expression An expression that returns an Application object.

MacroName Required String. The name of the macro, add-in, or script.

Return Type

Void


Run Method Example

This example runs a macro from another procedure.

Note To run this example, you must have a web named Rogue Cellars or you can substitute different web in place of the Rogue Cellars web. Copy the following procedures into a code module and run StartMacro.

Private Sub StartMacro()
Dim myMacro As String

myMacro = "OpenRogueCellars"
Run (myMacro)
End Sub

Sub OpenRogueCellars()
Dim myWeb As Web

Set myWeb = Webs.Open("C:\My Webs\Rogue Cellars")
End Sub


Save Method

Save a PageWindow object.

Syntax

expression.Save(ForceOverwrite)

expression An expression that returns a PageWindow object.

ForceOverwrite Optional Boolean. The ForceOverwrite argument can be used to write over an existing file. Default value is True.

Return Type

Void


SaveAs Method

Writes the specified PageWindow object to the destination URL.

Syntax

expression.SaveAs(DestinationUrl, ForceOverwrite)

expression An expression that returns a PageWindow object.

DestinationUrl Required String. A string that contains the entire URL for the web, such as “C:\My Documents\My Webs\Adventure Works\index.htm”. This can be any URL for a web, such as http://web server/folder/file or file://file system/folder/file for disk-based webs.

ForceOverwrite Optional Boolean. Default value is False.

Return Type

Void


SaveAs Method Example

This example saves an existing file to another web under a new name. (It isn't necessary to change the name of the file.) The program first activates the container web, and then opens the file so that a page window is established for the file. The page window is assigned to a variable and saved to a different web under a new name.

Note You must have a file named Zinfandel.htm in the C:\My Webs folder, or change the name of the file in the program to match an existing file in your web.

Private Sub SaveAsNewFile()
Dim myFile As WebFile
Dim myPageWindow As PageWindow

Webs.("C:\My Webs").Activate
Set myFile = ActiveWeb.RootFolder.Files("Zinfandel.htm")
myFile.Open
Set myPageWindow = ActivePageWindow
myPageWindow.SaveAs ("C:\My Webs\Rogue Cellars\Zinfandel Sale.htm")
myPageWindow.Close
End Sub


UndoCheckout Method

Returns the specified WebFile object to its prior state in the source control project.

Note You must have a source control project in place before using this method. For information about source control projects, refer to Managing Source Control Projects.

Syntax

expression.UndoCheckout()

expression An expression that returns a WebFile object.

Return Type

Void


UndoCheckout Method Example

This example checks a file in to its prior state (its state before checkout). The file must be part of a source control project.

Note To run this procedure, you must have a source control project in place with one web window open and a page called Zinfandel.htm contained in the web. Or, substitute a web and file of your choosing.

Private Sub UndoCheckout()
Dim myWeb As Web

Set myWeb = ("C:/My Webs/Rogue Cellars")
myWeb.RootFolder.Files("Zinfandel.htm").UndoCheckout
End Sub


Application Object

Application object

Represents the Microsoft FrontPage application. The Application object includes properties and methods that return top-level objects. For example, the ActiveDocument property returns a document object that references the FrontPage Page object model that is compatible with Microsoft Internet Explorer 4.0 and later.

Using the Application Object

Use the Application property to return the Application object. You can use the Application property from any of the objects in FrontPage. The following example checks the current user’s logon and sets appropriate security settings from the active Web object.

Private Sub GetLogonName()
Dim myWeb As Web
Dim currLogonName As String
Dim userSecurityLevel As Integer

Set myWeb = ActiveWeb
CurrentLogonName = myWeb.Application.UserName

If CurrentLogonName = “Guest”
    userSecurityLevel = 10
Else
    Call CheckUserName(currLogonName)
End If
End Sub

Many of the properties and methods that return the most common user-interface objects, such as the ActiveDocument property, can be used without the Application object qualifier. For example, instead of writing Application.ActiveDocument.Title, you can write ActiveDocument.Title. Properties and methods that can be used without the Application object qualifier are considered "global." To view global properties and methods in the Object Browser, click <globals> at the top of the list in the Classes box of the Object Browser.

Remarks

To use Automation to control FrontPage from another application, use the CreateObject or GetObject function to return a FrontPage Application object. The following Microsoft Word Visual Basic for Applications example starts FrontPage, opens an existing web, and closes the web.

Private Sub StartFrontPage()
Dim myNewFP As Variant

Set myNewFP = CreateObject("FrontPage.Application")
myNewFP.Webs.Open ("C:\MyWebs\Adventure Works")
myNewFP.Webs.Close "(C:\MyWebs\Adventure Works")
Set myNewFP = Nothing
End Sub


MetaTags Collection Object

An array of PropertyKey/Value pairs. Each MetaTag object represents a META tag contained on an HTML page in Microsoft FrontPage. The MetaTags collection is a member of the WebFile object.

Note META tags generated by FrontPage, such as META tags for a theme or border, won't show up in the MetaTags collection. The MetaTags collection is only propagated after the file is saved. For example, if you add a new META tag to a page by using the HTML view or by programmatically using the Page object model in Microsoft Visual Basic for Applications, you won't be able to view the PropertyKey/Value pairs until after you save the page. To save space in the META dictionary, you can use the following methods to disable the META tag store:

  • Set the DisableMetaTagStore key on a per-service basis

  • Set the DisableMetaTagStore key as a global setting under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\All Ports

  • Set the vti_disablemetatagstore property

The DisableMetaTagStore key functions in the same way as other server settings, see the Server Extensions Resource Kit for more information on server settings.

Using the MetaTags Collection

Use the MetaTags property to return the MetaTags collection.

HTML Note In the meta data for FrontPage, the HTTP-EQUIV attribute can be used in place of the NAME attribute. FrontPage doesn't use the value of HTTP-EQUIV attribute in response message headers. The syntax for META data is as follows:

<META
CONTENT=description
HTTP-EQUIV=text
NAME=text
TITLE=text
URL=url
>

You can also return a list of the META tags that exist in the active web, by accessing the file structure through the root folder of the ActiveWeb object, as shown in the following example.

Note To run this example, create a form with a text box called txtMetaTags (set to multiple lines) and a command button called cmdGetMetaTagInfo, and copy the example into the code window.

Private Sub cmdGetMetaTagInfo_Click()
Dim myWeb As Web
Dim myFiles As WebFiles
Dim myFile As WebFile
Dim myMetaTags As MetaTags
Dim myMetaTag As Variant
Dim myFileName As String
Dim myMetaTagName As String
Dim myReturnInfo As String

Set myWeb = ActiveWeb
Set myFiles = myWeb.RootFolder.Files

With myWeb
    For Each myFile In myFiles
        Set myMetaTags = myFile.MetaTags
        For Each myMetaTag In myMetaTags
            myFileName = myFile.Name
            myMetaTagName = myMetaTag
            myReturnInfo = myFileName & ": " & myMetaTagName
            txtMetaTags.Text = txtMetaTags.Text & myReturnInfo
        Next
    Next
    txtMetaTags.SetFocus
    txtMetaTags.CurLine = 0
End With
End Sub

Use the Application property to return the Application object. The following statement returns the Application object.

myAddInsCount = ActiveWeb.RootFolder.Files(0).MetaTags.Application

Use the Count property to return the number of MetaTag objects in the collection. The following statement returns the number of MetaTag objects in the tenth file of the ActiveWeb object.

myMetaTagCount = ActiveWeb.RootFolder.Files(9).MetaTags.Count

Use Items(index), where index is the PropertyKey value as a string, of an item in the MetaTags collection to return the PropertyKey/Value pair. The following example returns the program identification tag from the META tags in the first file of the ActiveWeb object.

myMetaTagOne = ActiveWeb.RootFolder.Files(0).MetaTags("ProgId")

Common PropertyKey values are "generator" and "progid". For more information on PropertyKey values, see the table in the Properties object.

Use the Parent property when you want to return the file container for the MetaTags collection. For example, the following example returns the Url property of the WebFile container object that is associated with the META tags for the first file of the ActiveWeb object.

myMetaTagParent = _
    ActiveWeb.RootFolder.Files(0).MetaTags.Parent.Url


NavigationNode Object

NavigationNodes collection (NavigationNode)
Represents a node in the navigation structure of a web. The NavigationNode object is a member of the NavigationNodes collection. Within the NavigationNodes collection, individual NavigationNode objects are indexed beginning with zero.

Important From the NavigationNode object, you can access all other navigation nodes in a web. The RootNavigationNode object, created by default each time you create a new web, provides the basis for the navigation structure, which is accessed through the Children property. The first child node of the navigation structure is usually the home page of the web, which can be accessed through the HomeNavigationNode property. However, the first child node of the root navigation node can be any page, and may not contain a HomeNavigationNode object at all.

Using the NavigationNode Object

You can use the NavigationNode property to return the NavigationNode object. The following example builds a list of navigation node labels for the WebFile object of the WebFiles collection.

Private Sub GetNavigationNode()
Dim myWeb As Web
Dim myWebFiles As WebFiles
Dim myWebFile As WebFile
Dim myNavNodeLabel As String
Dim myLabel As String

On Error Resume Next

Set myWeb = ActiveWeb
Set myFiles = myWeb.RootFolder.Files

With myFiles
    For Each myFile In myFiles
        myLabel = myFile.NavigationNode.Label
        If Err <> 0 Then Exit Sub
        myNavNodeLabel = myNavNodeLabel & myLabel & vbCRLF
    Next
End With
End Sub

The Children property returns the collection of child nodes within the navigation structure of a web. The following statement returns the number of child nodes within the navigation structure of the active web.

myNavChildrenCount _
    = ActiveWeb.RootFolder.Files(0).NavigationNode.Children.Count

Use Children(index), where index is the index number of a navigation node item, to return a single NavigationNode object. The following statement returns the file name of the first navigation node in the NavigationNodes collection.

myNavNodeName _
    = ActiveWeb.RootFolder.Files(0).NavigationNode.Children(0).File.Name

The File property returns the File object that is associated with the NavigationNode object. The following statement returns True if the file is open.

myNavFile = ActiveWeb.RootFolder.Files(3).NavigationNode.File.IsOpen

The Home property returns the Home object associated with the current navigation node and references information such as the Children, File, Label, Next, Prev, and other properties for the home page. The following statement returns the URL of the Home property for the NavigationNode object.

myHomePageUrl _
    = ActiveWeb.RootFolder.Files(5).NavigationNode.Home.Url

You can return the Label property to set or return text that can be used as buttons within the navigation structure, or used for text in a navigation bar. The following example returns the label for the home page.

myLabel = ActiveWeb.RootFolder.Files(0).NavigationNode.Label

Use the Next, Parent, Prev, or Url properties to return navigation nodes associated with the specified property. The following example returns the URL that is associated with the previous NavigationNode object.

myPrevNode = ActiveWeb.RootFolder.Files(1).NavigationNode.Prev.Url

Use the Web property to return the Web object associated with the current navigation node. The following example returns the Web object for the current navigation node.

myNavNodeWeb = _
    ActiveWeb.RootFolder.Files(2).NavigationNode.Web.Url

Use the Move method to move a navigation node from one child node to another. The following example moves a navigation node to a child location on a sibling node in the same web.

Private Sub MoveNavNode()
Dim myNodes As NavigationNodes
Dim myNode As NavigationNode

Set myNodes = ActiveWeb.RootNavigationNode.Children
Set myNode = myNodes(4)

myNode.Move myNodes, myNodes(2)
ActiveWeb.ApplyNavigationStructure
End Sub


NavigationNodes Collection Object

NavigationNodes collection (NavigationNode)

A collection of NavigationNode objects within the navigation structure of a Microsoft FrontPage-based web. Each NavigationNode object represents a pointer to a page on a web. The NavigationNode object is a member of the NavigationNodes collection.

Using the NavigationNodes Object

Use the NavigationNode property to return the NavigationNode object for a WebFile object. For more information on returning the collection of child nodes within the navigation structure of a web, see the Children property. The following example builds a list of the navigation labels that are associated with each NavigationNode object in the NavigationNodes collection. The procedure exits when it reaches the end of the navigation structure.

Private Sub GetNavigationNode()
Dim myWeb As Web
Dim myWebFiles As WebFiles
Dim myWebFile As WebFile
Dim myNavNodeLabel As String
Dim myLabel As String

On Error Resume Next

Set myWeb = ActiveWeb
Set myFiles = myWeb.RootFolder.Files

With myFiles
    For Each myFile In myFiles
        myLabel = myFile.NavigationNode.Label
        If Err <> 0 Then Exit Sub
        myNavNodeLbl = myNavNodeLabel & myLabel & vbCRLF
    Next
End With
End Sub

Use Children(index), where index is the index number of an item in the collection of child nodes, to return a single NavigationNode object. The following example returns the first NavigationNode object in the collection—which is the Home page.

Set myNavNodeOne = ActiveWeb.RootNavigationNode.Children(0)

Use the Add method to add a NavigationNode object to the NavigationNodes collection. The following example adds a navigation node to the rightmost position in the current navigation structure.

Private Sub AddNewNavNode()
Dim myWeb As Web
Dim myNewNavNode As NavigationNode
Dim myNavChildren As NavigationNode

Set myWeb = ActiveWeb
Set myNavChildren = _
    myweb.rootfolder.Files(1).NavigationNode.Children
myNewNavNode = _
    myNavChildren.Add("C:\My Webs\Sale.htm", "Sale", fpStructRightmostChild)
myWeb.ApplyNavigationStructure
End Sub

Note After you finish modifying your navigation structure, you must apply the changes using the ApplyNavigationStructure method before the navigation structure is updated in FrontPage.


PageWindow Object

Represents an open editor session and encapsulates the Microsoft FrontPage Page object model that is compatible with the document object model for Microsoft Internet Explorer 4.0 and later. The PageWindow object is a member of the PageWindows collection and represents all of the open page windows in the specified web. Within the PageWindows collection, individual PageWindow objects are indexed beginning with zero.

Note You can also substitute the Caption property of the PageWindow object instead of the index number when accessing a PageWindow object. The following statements return the PageWindow object for an open page window that has a caption of "C:\My Webs\Rogue Cellars\Zinfandel.htm").

Set myPageWindow = ActiveWebWindow.PageWindow("Zinfandel.htm")
Set myPageWindow = WebWindows(0).PageWindow("Zinfandel.htm")

Using the PageWindow Object

Use PageWindows(index), where index is the index number of a page window item, to return a single PageWindow object. The following statement returns the file URL of the first page window item in the PageWindows collection.

myPageOne = WebWindows(0).PageWindows(0).Document.Url

Use the ActiveFrameWindow property to return the active frame of a PageWindow object. The following statement returns the ActiveFrameWindow object.

Note The active frame is the frame that currently has the focus, it is shown in FrontPage with a blue border surrounding it.

Set myActiveFrame _
    = WebWindows(1).ActivePageWindow.ActiveFrameWindow

Use the FrameWindow property to return an IHTMLWindow2 object, which can then be used to return the frames collection and the content of each of the frames collection pages.

myFrameWindow = WebWindows(0).ActivePageWindow.FrameWindow

Use the Document property to return the document associated with the PageWindow object. The following statement returns the document associated with the first PageWindow object of the first WebWindow object.

Set myDoc = WebWindows(0).PageWindows(0).Document

You can use the IsDirty property to determine if the PageWindow object is dirty—that is, it has been modified since the last refresh or save. Returns True if the PageWindow object is dirty. The following example saves the PageWindow object if the first item in the PageWindows collection is dirty.

Private Sub CheckPageWindowIsDirty()
Dim myPageWin As PageWindow

Set myPageWin = WebWindows(0).PageWindows(0)

If myPageWin.IsDirty = True Then
    myPageWin.Save
End If
End Sub

You can use the ViewMode property to set the view for the page as shown in the following statement. For more information on the enumerated constants available for this property, see the table under the ViewMode property.

WebWindows(1).PageWindows(1).ViewMode = fpPageViewHtml


PageWindows Collection Object

A collection of PageWindow objects. Each PageWindow object represents an open web page in a Microsoft FrontPage application window. The PageWindow object is a member of the PageWindows collection.

Using the PageWindows Object

Use the PageWindows property to return the PageWindows collection. The following statement returns the PageWindows object to the myPages variable.

myPages = WebWindows(0).PageWindows

Use PageWindows(index), where index is the index number of an item in the PageWindows collection, to return a single PageWindow object. The following statement returns the first PageWindow object in the collection.

Set myPageWindow = WebWindows(0).PageWindows(0)

Use the Add method to add a page window to the PageWindows collection. The following example opens the specified page in myWebOne and adds the page to the PageWindows collection.

Dim myPageWindows As PageWindows
Set myPageWindows = ActiveWeb.WebWindows(0).PageWindows
myPageWindows.Add("C:\My Webs\myWebOne\bugrep.htm")

Use the Application property to return the Application object from within the PageWindows collection. The following example returns the Application object from within the PageWindows collection.

myAppName = WebWindows.PageWindows.Application.Name

Use the Close method to close a PageWindow object or the collection of open PageWindows. The following statement closes the fourth PageWindow object for the first WebWindow object.

WebWindows(0).PageWindows(3).Close

Use Close(index), where index is the index number of an item in the PageWindows collection, to close a single PageWindow object as shown in the following statements. Both statements close the same page window. In the first statement, you close the page window using the index number for the Close method, while in the second statement, you close the page window by specifying the index number for the page you want to close.

WebWindows(0).PageWindows.Close (2)
WebWindows(0).PageWindows(2).Close

Use Close() to close all of the open PageWindow objects in the PageWindows collection. The following statement closes all of the open pages in the PageWindows collection.

WebWindows(0).PageWindows.Close()

Use the Count property to return the total number of page windows in the PageWindows collection. The following example returns the number of page windows in the collection of PageWindows.

myPageCount = WebWindows(0).PageWindows.Count

Use the Parent property when you want to return the container for the PageWindows collection. The following statement returns the WebWindow container object for the first PageWindow object using the Parent property.

Set myParent = ActiveWeb.WebWindows(0).PageWindows.Parent


Properties Collection Object

A collection of meta data as Property objects. Each item in the Properties collection represents an item associated with an individual Web, WebFile, or WebFolder object. For more information, refer to the table of PropertyKeys in Using the PropertyKeys. Choose a topic from the following list to go directly to that topic.

Using the Properties Object

Using the Properties Collection Within a Web

Using the PropertyKeys

Using the Properties Object

Use the Add method to add a property to the Properties collection. The following statement adds a copyright statement to the Properties collection.

ActiveWeb.Properties.Add "Copyright", _
    “Copyright 1999 by Rogue Cellars”)

You can also add and remove categories and approval levels.

Use the ApplyChanges method to apply a Property object that has been added to the collection of Properties. The following statements add and apply a copyright property to the Properties collection.

ActiveWeb.Properties.Add "Copyright", _
    “Copyright 1999 by Rogue Cellars”)
ActiveWeb.Properties.ApplyChanges

Use the Count property to return the total number of properties in the Properties collection. The following example checks that the number of properties in the Properties collection has increased since the Copyright property was added and applied to the collection, and then goes on to add the copyright to a web page.

Note   To run this example, you must have a web called "C:\My Documents\My Webs\Rogue Cellars" (for a server running on Microsoft Windows) or "C:\WINNT\Profiles\logon alias\Personal\My Webs\Rogue Cellars" (for a server running on Windows NT). In either case, you may substitute an alternative web URL or file.

Private Sub copyrightAdd()
Dim myWeb As Web
Dim myCopyright As String
Dim myCount As Integer
Dim myMessage As String

myCopyright = "Copyright 1999 by Rogue Cellars"
myCount = ActiveWeb.Properties.Count
myMessage = "No new properties have been added."

Set myWeb = Webs.Open("C:\My Webs\Rogue Cellars")
myWeb.Activate
ActiveWeb.Properties.Add "Copyright", myCopyright

If myCount <> ActiveWeb.Properties.Count – 1 Then
    MsgBox myMessage
    Exit Sub
End If

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

Use the Delete method to delete a single property. The following statement deletes the Copyright property from the Properties collection.

ActiveWeb.Properties.Delete("Copyright")

Use the Parent property when you want to return the container for the Properties collection. For example, the following statement returns the URL of the parent web.

myParentURL  = ActiveWeb.Properties.Parent.Url

Using the Properties Collection Within a Web

Use Properties(index), where index is the PropertyKey of the item in the Properties collection, to return a single property. The following example returns the value of the PropertyKey vti_hassearchbot.

Private Sub CheckForSearchBot()
Dim myProperties As Properties
Dim myFoundSearchBot As Boolean

Set myProperties = ActiveWeb.Properties

With myProperties
    myFoundSearchBot = .Item("vti_hassearchbot")
End With
End Sub

Important   The values for properties are variant—that is, each value can be a string, a Boolean, or an array. You can use the Typename() function to determine the type of the property value.

Note   To run the following example you must create a form that contains a text box called txtCategories. Also, notice that myCategories is declared as a variant type in this example. In a previous example, myFoundSearchBot was declared Boolean—but could also have been declared as a string.

Private Sub GetWebPropertyCategories()
Dim myProperties As Properties
Dim myCategories As Variant
Dim myCategory As Variant
Dim txtCategories As String

Set myProperties = ActiveWeb.Properties

With myProperties
    myCategories = .Item("vti_categories")
    For Each myCategory In myCategories
        txtCategories = txtCategories & "|" & myCategory
    Next
End With
End Sub

Using the PropertyKeys

The property keys can be a valuable tool for organizing information about your webs. For example, you can add categories to the master list of categories on your web.

Important   The category names can be added to the categories list using case sensitivity, but will not display with case sensitivity in the User Interface (UI). Because of this, a situation may occur where a user creates a category on the client, such as "Web Administrators", and a duplicate category exists on the server, such as "web administrators". In this case, in the UI, FrontPage will assign both categories to the "web administrators" category and neither of these can be deleted from the web (in the UI). Programmatically, the case sensitivity will correctly display in the Immediate and Local windows of the Visual Basic Editor.

The following example first adds a category to the properties for the active web, deletes the Waiting category from the same list (vti_categories), and then adds the new category to each of the files in the active web.

Note   When creating a new category, you must first add the new category to the web before you add it to any of the files. The procedure, AddCategories, adds a new category to the web and the next procedure, AddCategoryToFiles, adds the same category to all of the files in the web.

Private Sub AddCategories()
Dim myWeb As Web
Dim myCategory(2) As String
Dim myItem As Variant

Set myWeb = ActiveWeb
myCategory(0) = "+web administrators"
myCategory(1) = "-waiting"
ActiveWeb.Properties("vti_categories") = myCategory
ActiveWeb.Properties.ApplyChanges

'List all of the items in vti_categories in the Immediate window
For Each myItem In myWeb.Properties("vti_categories")
    Debug.Print myItem
Next
End Sub

Private Sub AddCategoryToFiles()
Dim myWeb As Web
Dim myCategories(1) As String
Dim myFiles As WebFiles
Dim myFile As WebFile
Dim myItem As Variant

Set myWeb = ActiveWeb
Set myFiles = myWeb.RootFolder.Files
myCategories(0) = "+web administrators"

For Each myFile In myFiles
    myFile.Properties("vti_categories") = myCategories
    myFile.Properties.ApplyChanges
    'List all the items in vti_categories in the Immediate window
    For Each myItem In myFile.Properties("vti_categories")
        Debug.Print myItem
    Next
Next
End Sub

Note   Although you can create new categories, such as "web administrators", that aren't included in the categories that are automatically installed with FrontPage, these new categories won't be visible in the User Interface (UI) until they are added to the web. Notice that in the previous example, the new category was added to the web first and will be visible in the UI.

The following table provides detailed information about the property keys available in FrontPage 2000. Notice that all property keys in FrontPage start with “vti_”. It is suggested that you prefix the property keys you want to add with a short name, such as an abbreviation for the name of your company, to reduce chances of naming conflicts with other properties.

Property Key | Description | Permission
vti_approvallevel | The approval level set for a page. The available levels are AssignedTo, ReviewStatus, and Categories. | Read/write
vti_approvallevels | List of available approval levels that can be applied to documents in a web. This property key is a string vector (or an array of strings). Used to populate the web-wide list of known "review statuses" (also known as "approval levels") that are set for a document. The approval levels you can set are AssignedTo, ReviewStatus, and Categories. | Read-only
vti_approvedby | The authenticated name of the person who approved the page. | Read-only
vti_assignedby | The authenticated name of the person who assigned the page to a user. | Read-only
vti_assigneddate | This is the date that the page was last assigned to a user. | Read-only
vti_assignedto | The authenticated name of the person to whom the page is assigned. | Read-only
vti_author | Returns the author's name in string format. The identification of the authenticated author who has, or is, making changes to the document. Note This is different from the Author property stored as part of Microsoft Office document properties, which can be set by the user to any arbitrary value. | Read-only
vti_casesensitiveurls | True if the web is running on a server where URLs are case sensitive, such as a server running UNIX. For example, if this property is set to True, then a file named MyFile.htm and a file named myFile.htm are treated as two separate files. | Read-only
vti_categories | The master list of categories. This property key is a string vector (or an array of strings) that is used for both web-level and document-level meta data. At the web level, the property key contains a list of all known categories that exist in the web. At the document level, it contains a list of all the categories to which the specified document belongs. Note These categories are automatically updated whenever a category is added or modified in any way. | Read/write
vti_clientvercutoff | You can use this property key to set a version cutoff string. This is most commonly used in a multi-version environment to prevent older versions of the application from running on a specific server. For more information, see the FrontPage Server Extensions Resource Kit. | Read/write
vti_dataconns | List of data connections used by database features in FrontPage. | Read-only
vti_defaultcharset | The default character set for the web or page. | Read-only
vti_defaultlanguage | The default language for the web or page. | Read-only
vti_description | Provides a multi-line text box for the user to write comments in. | Read/write
vti_donotpublish | Set to True if the page is marked as "draft" or "not to be published." | Read/write
vti_filesize | The size of the file in bytes. | Read-only
vti_generator | This property key corresponds to the generator tag within an HTML document. The value of the vti_generator property key contains the name of the application that "generated" the document, which may be different from the application that was invoked to handle the page. For example, if you created or edited a page with Microsoft Word, and then retrieved the value of the vti_generator property key in Microsoft Visual Basic for FrontPage for that document, the value of the vti_generator property key would be Microsoft Word--even though the procedure call was generated by FrontPage. Valid values are "Microsoft Word", "Microsoft Access", "Microsoft FrontPage", and so on. Note FrontPage defers to Word when there's a theme conflict if the vti_generator property key contains "Microsoft Word". | Read-only
vti_globalpage | Marks a page as global, that is, a top level page in the navigation structure, on the same level as, but not equal to, the home page. | Read/write
vti_hasframeset | True if the page contains framesets. This property key is used when constructing navigation bar links. When the page that is being linked is a frameset, the link's target attribute is forced to "_top". This causes the new page to replace the current frameset to prevent recursive framesets at browse time. | Read-only
vti_hasruntimebots | True if the page has run-time bots on it. | Read-only
vti_htmlextensions | A concatenated string of extensions used to specify a web file, such as htm.html.asp. | Read-only
vti_httpdversion | The version of FrontPage that is running on the httpd server. | Read-only
vti_imagemapformat | This property key sets the URL format used by the server-side image map processor. Valid values are NCSA and CERN. This property key is only useful for prior versions of FrontPage. FrontPage 2000 now uses client-side image maps. | Read/write
vti_imagemapurlprefix | Sets the server-relative URL of the server-side image-map processor for the selected image-map format. If the value of the vti_imagemapurlprefix property key is set to an empty string (""), server-side image maps are handled automatically by the FrontPage Server Extensions. For other formats, provide the name and location of the image-map processor. To specify client-side image maps, set this variable to an empty string. For more detailed information, refer to the FrontPage Server Extensions Resource Kit. | Read/write
vti_insecureserverurl | Retrieves the http:// URL (unsecured URL) for a Web site. Provides compatibility with older browsers that may not have secure browsing capability. For more information, see the FrontPage Server Extensions Resource Kit. | Read-only
vti_isbrowsable | True if the page folder is browsable. Use Folder.IsBrowsable to set this value.. | Read-only
vti_ischildweb | True if the specified folder is the root of a subweb. Use Folder.MakeWeb and Folder.RemoveWeb to modify. | Read-only
vti_isexecutable | Set this property to True to enable if this folder is marked for executable content on the server. Use Folder.IsExecutable to set this value. | Read/write
vti_isscriptable | Set this property to True to if enable scripting is enabled for a this folder. Use Folder.IsScriptable to set this value | Read-write
vti_longfilenames | True if the server supports file names that are longer than the standard 8.3 file format. (The 8.3 file format only supports file names with eight characters and extensions with three characters, such as "filename.txt".) | Read-only
vti_metatags | This property key corresponds to the contents within the META tags in an HTML document. All of the information contained in this property key is added to the META tags collection. | Read-only
vti_modifiedby | Authenticated name of the author who last modified the page. | Read-only
vti_navbuttonhomelabel | The image file associated with the button that links to the home page. Note This image is retrieved from the theme associated with the file and is not customizable. | Read/write
vti_navbuttonhomelabeltext | The text that overlays the vti_navbuttonhomelabel. Note This text is customizable by the user. | Read/write
vti_navbuttonlabeltext | The text that overlays the vti_nvabuttonuplabel. Note This text is customizable by the user. | Read/write
vti_navbuttonnextlabel | The image file associated with the button that links to the next page in the navigation structure. Note This image is retrieved from the theme associated with the file and is not customizable. | Read/write
vti_navbuttonnextlabeltext | The text that overlays the vti_navbuttonnextlabel. Note This text is customizable by the user. | Read/write
vti_navbuttonprevlabel | The image file associated with the button that links tot he previous page in the navigation structure. Note This image is retrieved from the theme associated with the file and is not customizable. | Read/write
vti_navbuttonprevlabeltext | The text that overlays the vti_navbuttonprevlabel. Note This text is customizable by the user. | Read/write
vti_navbuttonuplabel | The image file associated with the button that links to the page one level up in the navigation structure. Note This image is retrieved from the theme associated with the file and is not customizable. | Read/write
vti_noclientimagemaps | True if client image maps are prohibited. | Read-only
vti_nonnavpage | True if the page isn't associated with a navigation node within the navigation structure. | Read/write
vti_nosourcecontrol | True if the web is not being stored under source control. Prevents adding a file to source control if this property is set to True. Note If a file has previously been added to a source control project with the vti_nosourcecontrol property set to False, and the property is subsequently set to True, the file will not be removed from the source control project. | Read/write
vti_originator | This property key corresponds to the "originator" META tag in an HTML document. The value of this property key contains the name of the application that created the document. You should never overwrite this property key with the name of another application. The vti_generator property key should be used to track the application that last "generated" the HTML page. Simply editing a document in FrontPage will change the value of the vti_generator property key to "Microsoft FrontPage". Valid values are "Microsoft Word", "Microsoft Access", "Microsoft FrontPage", and so on. Note FrontPage defers to Word when there's a theme conflict if the vti_generator property key contains "Microsoft Word". | Read-only
vti_privatetext | The value of this property key must be an integer. Zero or not present is the default. A non-zero value means that the page won't be added to any text indexes. This property key only works with the built-in text indexing in FrontPage and is not recognized by Microsoft Internet Information Services (IIS). | Read/write
vti_progid | This corresponds to the "progid" META tag in an HTML document. The value of this property key determines which application opens the document when a user clicks (or double-clicks) the document's file name in Windows Explorer. Valid values are "FrontPage.Editor.Document", "Word.Document", "Excel.Sheet", "PowerPoint.Slide", "Access.Application". Note FrontPage defers to Word when there's a theme conflict if the vti_generator property key contains "Microsoft Word". | Read-only
vti_scriptlanguage | Indicates which scripting language is enabled on the server. | Read-only
vti_secureserverurl | Retrieves the https://URL (secured URL) for a Web site. Provides a secure environment for confidential transactions over the Internet. For more information see the FrontPage Server Extensions Resource Kit. | Read-only
vti_serveripaddress | The IP address of the server. Note An IP address beginning with 127 represents a local server. | Read-only
vti_serverlanguage | The language of the operating system. Used for localization purposes. | Read-only
vti_showhiddenpages | True if hidden pages are displayed. | Read-only
vti_sourcecontrolcheckedoutby | Authenticated name of the author who last checked out a page. | Read-only
vti_sourcecontrolerror | The error last returned by the source control system. This error is added to the META tag information if an error occurs while the file is being added to a source control project. | Read-only
vti_sourcecontrolproject | The name of the source control project. For a Microsoft Visual SourceSafe project, the string would include the "$" symbol, as in "$/myProject" | Read-only
vti_sourcecontrolsystem | The value of this property key is the type of source control in use on that web. Can be Microsoft Visual SourceSafe or Microsoft Frontpage Light Weight source control. Valid values for these two types of source control are "VSS" and "LW", respectively. This property key is set when a source control project is started. For more information on source control projects, refer to Managing Source Control Projects. | Read-only
vti_sourcecontrolversion | A numbered string that contains the version of the source control system that is in use. | Read-only
vti_textextensions | A concatenated string of extensions that are commonly used to denote text files. For example, the concatenated string might contain ".txt.rpt..." | Read-only
vti_themedefault | The default theme of the web. | Read-only
vti_themesusecss | True if CSS is used to present the theme. | Read/write
vti_timecreated | The timestamp when the page was created. The timestamp is in Universal Time Coordinate (UTC) or Greenwich time. | Read-only
vti_timelastmodified | The time that the page was last modified. The timestamp is in UTC time. This is only set when the author edits the page directly. | Read-only
vti_timelastwritten | The time that the page was last rewritten. The timestamp is in UTC time. | Read-only
vti_-title | The value of the text between the <TITLE> tags on the page. | Read-only
vti_usernames | The list of known user names for a specified web. | Read-only
vti_webservertype | The type of Web server. Valid values include, "MSIIS" for Microsoft Internet Information Services and "PWS" for Personal Web Server. | Read-only
vti_welcomenames | A concatenated list of file names that can be used as the file name for the home page, such as "index.htm index.html default.htm". | Read-only


System Object

Represents the Microsoft FrontPage accessor for the System object and provides access to information such as the operating system, screen resolution, or registry information.

Using the System Object

Use the System property to return the System object. The following statement returns the name of the calling application.

mySysApp = System.Application.Name

Use the Build and Version properties to return build and version information about the operating system.

myVer = System.Version
myBld = System.Build

The horizontal and vertical resolution can be used to determine if a graphic can be displayed on a client’s machine. The following statements return the resolution settings.

currHorizRes = System.HorizontalResolution
currVertRes = System.Vertical.Resolution

Use the OperatingSystem property to return the name of the current operating system as shown in the following statement.

thisOps = System.OperatingSystem

Use the Parent property to return the parent of the specified object. The following statement returns parent information for the System object.

Private Sub GetSystemParentInfo()
Dim mySys As System
Dim mySysUserName As String

Set mySys = System

With mySys
    mySysUserName = .Parent.UserName
End With
End Sub

Use the LanguageDesignation property to return a three-letter abbreviation for the language used for the operating system. The following statement returns "enu" as the language designation abbreviation for the English (US) language.

currSystemLanguage = System.LanguageDesignation

Use the ProfileString(Section As String, Key As String, Value As String) property to return or set an entry in the Windows registry. If used without parameters, the ProfileString property defaults to the following key:

HKEY_CURRENT_USERS\Software\Microsoft\FrontPage

The parameters for the ProfileString property are:

  • RegistrySection, where RegistrySection is a registry subtree such as HKEY_CURRENT_USER or HKEY_LOCAL_MACHINE

  • RegistryKey, where RegistryKey is the next level below the section or subtree with such key names as Software or Network

The following example returns the Identifier for the CentralProcessor subkey.

Private Sub GetProfileString()
Dim mySys As System
Dim myRegSec As String
Dim myRegKeyInfo As String

Set mySys = System

myRegSec = _
 "HKEY_LOCAL_MACHINE\Hardware\Description\System\CentralProcessor\0"

myRegKeyInfo
    = mySys.ProfileString(myRegSec, "Identifier")
End Sub


Theme Object

Themes collection (Themes)

Represents a theme in Microsoft FrontPage. The Theme object is a member of the Themes collection. The Themes collection represents all of the themes on the local machine or applied to a specific web. Within the Themes collection, individual Theme objects are indexed beginning with zero.

Using the Theme Object

Use the Format property to return format information for a theme. The following statement returns the format for the theme applied to the active FrontPage-based web page.

myThemeFormat = Theme.Format

Use the Label property to return the name that is displayed in the Theme list box—this is the full name of the theme. The following statement returns the label for the theme.

myThemeLbl = Theme.Label

Use the Name property to return or apply a theme to a web page. The Name property contains the directory name for the theme—an abbreviated version of the name of the theme as displayed in the Theme list box. The following example returns the name of the theme associated with the ActivePageWindow object.

Note To run this example, you must have a web open that has a theme applied to the active page, the entire web, or a file in the web.

Private Sub GetThemeName()
Dim myPageWindow As PageWindow
Dim myThemeName As String

Set myPageWindow = ActivePageWindow
myThemeName = myPageWindow.Theme.Name
End Sub

Use the Version property to return the version number of the theme. The following example returns the version for a theme.

myThemeVersion = Theme.Version


Themes Collection Object

Themes collection (Themes)

A collection of Theme objects. Each Theme object represents a theme associated with an HTML page or a web in Microsoft FrontPage. The Theme object is a member of the Themes collection.

Using the Themes Collection

Use the Themes property to return the Themes collection. The Themes property can be used with either Application or Web objects. The Themes property for the Application object is the collection of themes available in FrontPage. The Themes property for the Web object is the collection of themes applied to the files within a web, or the collection of themes applied to a web. The following statement illustrates both the Themes and Count properties, and returns the number of items in the Themes collection that are available in FrontPage.

myTotalThemeCount = Application.Themes.Count

The following statement returns the number of themes within a web.

myWebThemeCount = Application.Webs(0).Themes.Count

Use Themes(index), where index is the index number of a theme item, to return a single Theme object. The following statement returns the first theme in the Themes collection.

myThemeOne = Web.Themes(0)

Use the Application property to return the Application object. The following example returns the version and build number of FrontPage from within the Themes collection.

Note To run this procedure you must have at least one open web.

Private Sub GetBuildNumber()
Dim myThemes As Themes
Dim myBuild As String

Set myThemes = ActiveWeb.Themes

myBuild = myThemes.Application.Build
End Sub

Use the Parent property when you want to return the container for the Themes collection. For example, the following statement returns the URL associated with the parent container of the Themes collection.

myParentUrl = Web.Themes.Parent.Url


Web Object

Represents a Microsoft FrontPage Web object. The Web object is a member of the Webs collection, which represents all of the open webs in a Web site. FrontPage provides the ability to create multiple Web objects on a Web server. Within the Webs collection, individual Web objects are indexed beginning with zero. The directory hierarchy of a Web site in FrontPage is similar to a folder hierarchy. Any WebFolder can represent a Web site, but every WebFolder does not necessarily represent a Web site. The Web folder hierarchy provides the link to folders and files on a Web server directory.

Using the Web Object Properties

Use the Web property to return the Web object. The following example checks the web’s operating system for the capability of processing long file names.

Note To run this example, create a form with a command button called cmdCheckLongFilenames, a text box called txtLongFilenames, and copy the example into the code window.

Private Sub cmdCheckLongFilenames()
Dim myPageWin As PageWindow

Set myPageWin = ActivePageWindow

With myPageWin
    If .Web.AllowsLongFilenames = True Then
        txtLongFilenames = _
            “This operating system uses long file names.”
        Exit Sub
    Else
        txtLongFilenames = _
            “This operating system only uses short file names.”
    End If
End With
End Sub

Use Webs(index), where index is the index number of a web item, to return a single Web object. The following example returns the URL of the first web item in the Webs collection.

Application.Webs(0).Url

Use the ActiveWebWindow property to return the selected ActiveWebWindow object. From the ActiveWebWindow object, you can access the ActiveDocument, ActivePageWindow, or Application objects, along with properties such as Caption, PageWindows, Parent, ViewMode, Visible, and Web. The following example returns the creation date and file size of the active document.

Note Although Date is an available type in Visual Basic for Applications, the ActiveDocument object returns the date in string format and does not automatically convert the string to a date format.

Private Sub ActiveDocDateSize()
Dim myWebWindow As WebWindow
Dim myFileSize As String
Dim myCreateDate As String

Set myWebWindow = ActiveWebWindow

With myWebWindow
    myFileSize = .ActiveDocument.fileSize
    myCreateDate = .ActiveDocument.fileCreatedDate
End With
End Sub

The RevisionControlProject and IsUnderRevisionControl properties return the status of the Web object’s revision state. You can control versioning in Microsoft FrontPage through Microsoft Visual SourceSafe or through Microsoft Office style locking. For more information on source control projects and Office style locking, refer to Managing Source Control.

If a revision control project does not correspond to a valid Visual SourceSafe project, FrontPage defaults to Office style locking. The following example returns the RevisionControlProject and IsUnderRevisionControl properties, and includes a source control project example.

Note To run this example, create a module and copy the example into the code window. You must have a web open.

Private Sub SourceControl()

Dim myWeb As Web

Set myWeb = ActiveWeb
If Not(myWeb.IsUnderRevisionControl) Then
    MyWeb.RevisionControlProject = "<FrontPage-based Locking>"
End If
End Sub

Private Sub ReturnRevisionState()
Dim myWeb As Web
Dim myRevCtrlProj As String
Dim myIsUnderRevCtrl As Boolean

Set myWeb = ActiveWeb

With myWeb
    myRevCtrlProj = .RevisionControlProject
    myIsUnderRevCtrl = .IsUnderRevisionControl
End With
End Sub

Use the RootFolder and RootNavigationNode properties to determine the root folder or root navigation node. The RootFolder property returns a pointer to the root folder of a Web site. The RootNavigationNode property returns the NavigationNode object from which you can access all other navigation nodes in a web. The RootNavigationNode object is created by default when you create a Web, and provides the basis for the navigation structure, which is accessed through the Children property. The first child node of the navigation structure is the home page of the web. The following example returns the name of the root folder and the URL of the RootNavigationNode object.

Private Sub GetRootInfo()
Dim myWeb As Web
Dim myRootFolder As String
Dim myHomeNavNode As String

Set myWeb = ActiveWeb

With myWeb
    myRootFolder = .RootFolder.Name
    myHomeNavNode = .RootNavigationNode.Children(0).Url
End With
End Sub

Use the SharedBorders property to set the shared borders for a web either on or off. The following statement sets the SharedBorders property to True and turns shared borders on for the specified web.

ActiveWeb.SharedBorders(fpBorderTop) = True

Use the WebWindows property to return the collection of WebWindow objects that are contained within the current Web object. The following statement returns a count of the WebWindows collection.

Application.WebWindows.Count

Using the Web Object Methods

Use the Activate method to place the focus on the current object. The following statements check if myAdventureWorksWeb is the active web; if it is not, then myAdventureWorksWeb is activated.

If ActiveWeb <> myAdventureWorksWeb Then
    myAdventureWorksWeb.Activate
End If

Use the ApplyNavigationStructure method to apply a newly created or modified navigation structure to a Web site. The following statement applies a navigation structure to a web, where the variable for the Adventure Works web is webAdventureWorks.

myAdventureWorksWeb.ApplyNavigationStructure

Use the CancelRequests method to cancel all server requests. The following statement cancels all server requests for the Adventure Works web, with webAdventureWorks as the web variable.

Note The client will stop all requests to the server; however, the server may have already started a transaction, in which case it will continue until the transaction is finished and then the remaining requests (if any) will be cancelled.

myAdventureWorksWeb.CancelRequests

Use the LocateFile or LocateFolder methods to return a WebFile or a WebFolder object within a web. The following example locates a folder for a disk-based web.

Application.Web.LocateFolder("C:\My Webs\Adventure Works\images")

Use the Publish method to publish a web to a Web server. The following statement publishes the Adventure Works web to a Personal Web Server site.

Dim myWeb As Web

Set myWeb = Application.Web

With myWeb
    .Publish _
    "http://myServer/wwwroot", fpPublishAddToExistingWeb

The FpWebPublishFlags enumerated types can be concatenated as shown in the following statement.

myWeb.Publish _
    "http://myServer/wwwroot", fpPublishAddToExistingWeb + _
    fpPublishCopySubwebs

Use the RecalcHyperlinks method to update the display all of the hyperlinks in a web. You may want to recalculate hyperlinks often when you have a multiuser environment with many people making changes to the web. When you recalculate hyperlinks, FrontPage also performs other processes such as deleting unused themes and updating component information on the server. The following statement recalculates the hyperlinks in the Adventure Works web.

webAdventureWorks.RecalcHyperlinks

Use the Refresh method to refresh a page. The following statements refresh a page and the active web.

myPage.Refresh
myWeb.Refresh


Webs Collection Object

A collection of Web objects. Each Web object represents a web on a Web server—which can either be disk-based (on a local hard drive) or server-based. For more information on FrontPage-based webs, see Creating Web Sites. The Web object is a member of the Webs collection.

Using the Webs Collection

Use the Webs property to return the Webs collection. You can also use the Application property to return the Application object. The following statement uses the Application object to return the first item in the Webs collection or, use the second statement to return the entire collection of webs.

Set myWebOne = Application.Webs(0)
Set myWebs = Application.Webs

Use Webs(index), where index is the index number of an item in the Webs collection, to return a single Web object. The following statement returns the third web in the collection of open Web objects.

Set myGetWebThree = Webs(2)

Use the Add method to add an item to the list of available items in the Webs collection. The following statement adds the Rogue Cellars web to the Webs collection.

Webs.Add("C:\My Documents\My Webs\Rogue Cellars")

Use the Application property to return information about the application from within the Webs collection. The following statement returns the version number of the Application object.

ActiveWeb.Webs.Application.Version

Use the Count property to return the number of open webs in the Webs collection. The following statement returns the number of open webs.

Webs.Count

Use the Delete method to permanently delete a web from the Webs collection. The following statement deletes the Rogue Cellars web.

Webs.Delete("C:\My Documents\My Webs\Rogue Cellars")

Use the Open method to open a web. The following statement opens a web and adds it to the collection of items in the Webs collection.

Webs.Open("C:\My Documents\My Webs\Rogue Cellars")

Use the Parent method when you want to return the container of the Webs collection, which is the application. The following statement returns the Application object.

Set myParent = Webs.Parent


WebFile Object

Represents a file in a Microsoft FrontPage-based web. The WebFile object is a member of the WebFiles collection. The WebFiles collection represents all of the files in a specified WebFolder object. Within the WebFiles collection, individual WebFile objects are indexed beginning with zero. The WebFile object is similar to a file in a directory-based hierarchy. FrontPage provides the ability to create multiple Web objects on a Web server. Any WebFolder can represent a Web site, but every WebFolder does not necessarily represent a Web site.

Using the File Object

Use WebFiles(index), where index is the index number of a web file item, to return a single WebFile object. The following example returns the file name of the first web file item in the WebFiles collection.

ActiveWeb.RootFolder.Files(0).Name

Use the File object to return information about a file on a web. The following example returns the Name, Title, and Url properties of each File object on the active web.

Note To run this program, you must have a least one web open.

Private Sub GetWebFileInfo()
Dim myWeb As Web
Dim myFiles As WebFiles
Dim myFile As WebFile
Dim myFileName As String
Dim myTitle As String
Dim myUrl As String

Set myWeb = ActiveWeb
Set myFiles = myWeb.RootFolder.Files

With myWeb
    For Each myFile In myFiles
            myFileName = myFile.Name
            myTitle = myFile.Title
            myUrl = myFile.Url
    Next
End With
End Sub

Use the IsOpen property to check if a file is currently open in Page view. The following example returns the IsOpen property for a specified File object. Notice that the Edit method is used to open the file in this example. For more information on using these methods, see the Edit method.

Note You must have a web open to run this program.

Private Sub CheckForOpenFile()
Dim myWeb As Web
Dim myFiles As WebFiles
Dim myFile As WebFile
Dim myFileToOpen As String
Dim myMessage As String
Dim myFileName As String

Set myWeb = ActiveWeb
Set myFiles = myWeb.RootFolder.Files

myFileToOpen = "index.htm"
myMessage = "This file is currently open."

With myWeb
    For Each myFile In myFiles
        myFileName = myFile.Name
        If myFileName = myFileToOpen Then
            If myFile.IsOpen = True Then
                MsgBox (myMessage)
                Exit Sub
            Else
                myFile.Edit fpPageViewNormal
                Exit Sub
            End If
        End If
    Next
End With
End Sub

Use the Checkin, Checkout, and UndoCheckout methods to manage file resources through source control on a web. The following statement checks out the first file in the active web.

Note You must have a source control project set up in order for this to work.

myFileCheckedOut = ActiveWeb.RootFolder.Files(1).Checkout

Similar to file management features in Microsoft Visual SourceSafe, FrontPage also provides an UndoCheckout method that you can use to return a file to its original state. The following statement returns the file to its original state.

myFileCheckedOut = ActiveWeb.RootFolder.Files(1).UndoCheckout

You can use the CheckedoutBy property before attempting to check out a file to see if the file is currently checked out and by whom. The following statement returns the logon alias of the person who checked out a file or is null if the file isn't currently checked out.

myWhoCheckedOutFile = ActiveWeb.RootFolder.Files(0).CheckedoutBy

Use the Properties property to return information about a web, such as the type of Web server (vti_webservertype) or if the web has a search bot (vti_hassearchbot). The Properties property returns a collection of key-value pairs used to maintain the meta information. The following statement returns True for the variable mySearchBot if the Web has a search bot.

mySearchBot = ActiveWeb.Properties.Item("vti_hassearchbot")

Use the MetaTags properties to return information about the meta tags contained in the HTML coding of a file. The MetaTags property returns a collection of meta tags for a File object, such as the generator of the file. The following example returns the file name and meta tags for each file in a web.

Note To run this program, you must have a least one web open.

Private Sub GetMetaTags()
Dim myWeb As Web
Dim myMetaTag As Variant
Dim myFiles As WebFiles
Dim myFile As WebFile
Dim myMetaTags As MetaTags
Dim myFileName As String
Dim myMetaTagName As String

Set myWeb = ActiveWeb
Set myFiles = myWeb.RootFolder.Files

With myWeb
    For Each myFile In myFiles
        Set myMetaTags = myFile.MetaTags
        For Each myMetaTag In myMetaTags
            myFileName = myFile.Name
            myMetaTagName = myMetaTag
        Next
    Next
End With
End Sub

Use the SharedBorders property to return the shared borders on the current web page, or to set new shared borders. The following statement returns the top shared border of the first file in the Files collection of the active web.

myTopBorder _
    = ActiveWeb.RootFolder.Files(0).SharedBorders(fpBorderTop)

You can also set shared borders on a web file, as shown in the following statement.

ActiveWeb.RootFolder.Files(0).SharedBorders(fpBorderTop) = True

Use the ThemeProperties property to return the following information about the applied theme: does the theme use vivid colors or active graphics? The following example returns the properties of an applied theme and adds vivid colors to the current theme properties if vivid colors haven't been applied to the specified object.

Private Sub CheckThemeProperties()
Dim myFile As WebFile

Set myFile = ActiveWeb.RootFolder.Files(0)

If myFile.ThemeProperties(fpThemeActiveGraphics) Then
    myFile.ApplyTheme myFile.ThemeProperties(fpThemeName), myFile.ThemeProperties(fpThemePropertiesAll) + fpThemeVividColors
Else
    myFile.ApplyTheme myFile.ThemeProperties(fpThemeName), myFile.ThemeProperties(fpThemePropertiesAll) + fpThemeActiveGraphics + fpThemeVividColors
End If
End Sub

Using File Methods

Use the Copy, Delete, Edit, Move, or Open methods to manage your web files. There's a subtle distinction between the Edit and Open methods. With the Edit method, you can open and modify a FrontPage-compatible file into a PageWindow object. With the Open method, you can open both FrontPage-compatible files and any other type of file such as image or text files, into the file's associated editor. When you use the Open method to open a file type that is not FrontPage-compatible, FrontPage does not return a file object. The following example opens a file, deletes a file, and moves a file.

Note To run this example, you must have a web called "C:\My Documents\My Webs\Rogue Cellars" (for a server running on Microsoft Windows) or "C:\WINNT\Profiles\logon alias\Personal\My Webs\Rogue Cellars" (for a server running on Windows NT).

Private Sub OpenFile()
Dim myWeb As Web
Dim myFile As WebFile

Set myWeb = Webs.Open("C:\My Documents\My Webs\Rogue Cellars")
myWeb.Activate
Set myFile = myWeb.RootFolder.Files("index.htm")
myFile.Open
End Sub

Private Sub DeleteFile()
Dim myWeb As Web
Dim myFile As WebFile

Set myWeb = ActiveWeb
Set myFile = myWeb.RootFolder.Files(0)

myFile.Delete
End Sub

Sub MoveFile()
Dim myWeb As Web
Dim myFile As WebFile

Set myWeb = ActiveWeb
Set myFile = myWeb.RootFolder.Files(0)

myFile.Move “New Filename”, True, True
End Sub


WebFiles Collection Object

A collection of WebFile objects. Each WebFile object represents all of the open files in a web. The WebFile object is a member of the WebFiles collection.

Using the WebFiles Object

Use the WebFiles property to return the WebFiles collection. The following statement returns the WebFile objects in the WebFiles collection.

Set myWebFiles = Application.Webs(0).RootFolder.WebFiles

Use WebFiles(index), where index is the index number of an item in the WebFiles collection, to return a single WebFile object. The following statement returns the first WebFile object in the collection.

Set myWebFile = ActiveWeb.RootFolder.WebFiles(0)

Use the Add method to add a WebFile object to the WebFiles collection. The following statement adds a new WebFile object to the collection of WebFiles.

myWebFiles.Add ("C:\New Web WebFiles\Sales Statistics.htm")

Use the Application property to return the Application object from within the WebFiles collection. The following statement returns the Application object from within the WebFiles collection.

myApp = ActiveWeb.RootFolder.WebFiles.Application

Use the Count property to return the number of open files in the WebFiles collection. The following statement returns the number of files in the collection of WebFiles.

myCount = Webs(0).RootFolder.WebFiles.Count

Use the Delete method to delete a WebFile object. The following statement deletes the third file in the WebFiles collection.

Webs(0).RootFolder.WebFiles(2).Delete

Use the Parent property when you want to return the container for the WebFiles collection. The following statement returns the URL of the folder for second file in the active web.

myWebFileParent = ActiveWeb.RootFolder.WebFiles(1).Parent.Url


WebFolder Object

Represents a folder in a Microsoft FrontPage-based web. The WebFolder object is a member of the WebFolders collection.

Note The Folder object is a pointer to the WebFolder object.

The WebFolders collection represents all of the folders in a specified web. Within the WebFolders collection, individual WebFolder objects are indexed beginning with zero. The WebFolder object is similar to a folder in a directory-based hierarchy, however, the relationship between WebFolder objects and Web objects is unique. FrontPage provides the ability to create multiple Web objects on a Web server. Any WebFolder can represent a Web site, but every WebFolder does not necessarily represent a Web site. The web folder hierarchy provides the link to folders and files on a Web server directory. The navigation structure provides the underlying structure for the Web objects within individual FrontPage-based webs.

Using the WebFolder Object

Use WebFolders(index), where index is the PropertyKey of a web folder item, to return a single WebFolder object. The following example returns the file name of the first web folder item in the WebFolders collection.

ActiveDocument.WebFolders(0).Name

Use the collection properties such as Files, Folders, or Properties to return the collection object for the specified item. The following statements return the first specified item in the collection for the active web.

myFileOne = ActiveWeb.RootFolder.Files(0)
myFolderOne = ActiveWeb.RootFolder.Folders(0)
myPropertyOne = ActiveWeb.Properties("vti_author")

Use the properties such as IsExecutable, IsReadable, IsRoot, and so on, to check for the specified state of the folder. If you have CGI scripts that you'd like to execute, you can add the scripts to a folder and set the IsExecutable property on that folder to True. When you have content in a folder that you'd like others to browse, you can set the IsReadable property to True. If you want to check whether the current folder is the root folder, you can use the IsRoot property.The following example checks if files in the current WebFolder object are executable, read-only, or located in a root folder.

Private Sub GetFolderInfo()
Dim myWeb As Web
Dim myFolder As WebFolder
Dim myIsExe As Boolean
Dim myIsReadable As Boolean
Dim myIsRoot As Boolean

Set myWeb = ActiveWeb
Set myFolder = myWeb.RootFolder.Folders(1)

With myFolder
    myIsExe = .IsExecutable
    myIsReadable = .IsReadable
    myIsRoot = .IsRoot
End With
End Sub

The IsExecutable, IsReadable, and IsWriteable properties return information about the state of the folder. The following examples show how to set the IsExecutable and IsReadable properties and read the IsWriteable property.

Note You cannot set the IsWriteable property, however you can set the IsExecutable and IsReadable properties for a WebFolder object.

Sub FolderProperties ()
Dim myFolder As WebFolder

Set myFolder = ActiveWeb.RootFolder.Folders(0)

If myFolder.IsWritable Then
    MsgBox "Folder, " & myFolder.Url & " is writable"
End If

If Not(myFolder.IsReadable) Then
    MyFolder.IsReadable = True
End If

If myFolder.IsExecutable Then
    MyFolder.IsExecutable = False
End If
End Sub

Folders (or WebFolders) in FrontPage serve two purposes. They can be folders that help manage the content of the web, or, they can be webs. A web can have multiple subwebs below it. The IsWeb property returns True if the folder in question is a web. The following example uses the IsWeb property to determine if a folder is a web and if so, opens the web.

Note To run this example, you must have a web called "C:\My Documents\My Webs\Rogue Cellars" (for a server running on Microsoft Windows) or "C:\WINNT\Profiles\logon alias\Personal\My Webs\Rogue Cellars" (for a server running on Windows NT). In either case, you may substitute an alternative web URL.

Private Sub CheckFolder()
Dim myFolder As WebFolder

Set myFolder = ActiveWeb.RootFolder.Folders("Rogue Cellars")
If myFolder.IsWeb = True Then
    Webs.Open myFolder.Url
End If
End Sub

Use the Url property to return the URL of the current WebFolder object. The following statement returns the absolute URL for the eighth folder in the active Web.

myUrl = ActiveWeb.RootFolder.Folders(7).Url

Use the Copy, Delete, and Move methods to maintain your web structure. The following statement copies a WebFolder object from one folder to another folder, updates the links during the copy process, and forces an overwrite if the file already exists.

myFolder.Copy("C:\My Webs\New Adventure Products", True, True)


WebFolders Collection Object

A collection of WebFolder objects. Each WebFolder object within the WebFolders collection represents an open folder in a web. The WebFolder object is a member of the WebFolders collection.

Note All of the methods that involve changing the location of a folder, such as Copy or Move, only change the location within the current web—you cannot change the location of a folder from the current web to a different web.

Using the WebFolders Object

Use WebFolders(index), where index is the index number of an item in the WebFolders collection, to return a single WebFolder object. The following example returns the first WebFolder object in the collection.

Set myFolder = ActiveWeb.RootFolder.Folders(0)

Use the Add method to add a new WebFolder object to the WebFolders collection in a web. Both of the following statements add a WebFolder to the collection of WebFolders in the active web—parentheses are not required for the folder name, as shown in the second statement.

Note The FolderUrl argument within the quotes ("Rogue Cellars") should only include the new folder name, not the entire URL, unless you are adding a new URL to the location designated as the FolderUrl. The program will fail if the entire URL is included for existing URLs.

ActiveWeb.RootFolder.Folders.Add ("Rogue Cellars")
ActiveWeb.RootFolder.Folders.Add "Rogue Cellars"

Use the Count property to return the number of total navigation nodes in the WebFolders collection. The following statement returns the number of webs in the Rogue Cellars web.

Webs("C:\Web Server One\Rogue Cellars").Folders.Count

Use the Delete method to delete a WebFolder object from the collection of WebFolders. The following statements delete the tenth WebFolder object. The second statement uses the name of the folder instead of the index number to designate the folder to delete.

ActiveWeb.RootFolder.Folders(9).Delete
ActiveWeb.RootFolder.Folders("TempFolder").Delete

Use the Copy method to copy a WebFolder object. The following example copies a folder (WebFolders(4)) to another folder on the active web (Chardonnay Inventory). For purposes of this example, WebFolders(4) is a folder in the Rogue Cellars web named Inventory. This folder contains the entire wine inventory—but the web designer wanted to feature the sale on Chardonnay wines, and so created a temporary folder that will be edited to contain only Chardonnay wine.

Private Sub CopyInventory()
Dim myFolder As WebFolder

Set myFolder = ActiveWeb.RootFolder.Folders(4)

myFolder.Copy ("C:\Rogue Cellars\Chardonnay Inventory, False, True)
End Sub

Use the Move method to move a folder from one location in a web to another. For example, if you had old advertising pages that you wanted to keep for the next quarter's sale, you could move them to another folder, as shown in the following example.

Private Sub MoveOldAds()
Dim myOldAds As WebFolder

Set myOldAds = Webs(0).RootFolder.Folders(1)

myOldAds.Move("C:\Rogue Cellars\FirstQtr Advertising", True, True)
End Sub

Use the Parent property when you want to return the container for the WebFolders collection. The following statement returns the container for the fourth folder.

myParent = Webs.RootFolder.Folders(3).Parent


WebWindow Object

Represents a window that is opened on a Microsoft FrontPage-based web. The WebWindow object is a member of the WebWindows collection. The WebWindows collection represents all of the open windows in a specified web or in FrontPage. Within the WebWindows collection, individual WebWindow objects are indexed beginning with zero. Each web that is opened in FrontPage is contained in a new WebWindow object, unless it is opened in a windowless environment by setting the Visible property of the WebWindow object to False. For more information on windowless environments, see Coding in a Windowless Environment.

Using the WebWindow Object

Use the WebWindow property to return information about an open WebWindow object. You can also use the PageWindows property to return information about the collection of open pages in a WebWindow object. The following example sets the WebWindow object to the active web window, and then returns the file names and dates that the files were last modified for the collection of open PageWindows objects within the WebWindow object.

Note To run this example, create a form with a command button called cmdWebWindowDisplay and a text box called txtWebWindowDisplay. You must have more than one page window open to display the iteration.

Private sub cmdWebWindowDisplay_Click()
On Error Resume Next
Dim openWebWindow As WebWindow
Dim openPageWindows As PageWindows
Dim thisPage As PageWindow
Dim CRLF As String
Dim myText As String

Set openWebWindow = Application.ActiveWebWindow
Set openPageWindows = openWebWindow.PageWindows
txtWebWindowDisplay.MaxLength = 1000
txtWebWindowDisplay.MultiLine = True
txtWebWindowDisplay.WordWrap = True
CRLF = Chr(13) & Chr(10)

With openWebWindow
    For Each thisPage in openPageWindows
        With thisPage
            myText = myText & "Open Page: " & .Caption _
            & CRLF & "Page Last Modified: " _
            & thisPage.Document.fileModifiedDate & CRLF & CRLF
        End With
    Next
txtWebWindowDisplay.Text = myText
End With
End Sub

Use WebWindows(index), where index is the index number of a web window item, to return a single WebWindow object. The following statement returns the ViewMode property of the first web window item in the WebWindows collection.

myViewMode = WebWindows(0).ViewMode

You can also use the ViewMode property to switch between view modes by setting the view mode as shown in the following statement, which switches the current view mode to the Navigation view.

ActiveWebWindow.ViewMode = fpWebViewStructure

The Activate method puts the focus on the specified WebWindow object. The following statements activates the first web in the collection of open web windows.

myWebWindow = WebWindows(0)
myWebWindow.Activate

The ActivePageWindow property returns the ActivePageWindow object. The following statements return the URL and the caption of the ActivePageWindow object. The value returned for the caption in this case is a file name, such as "Index.htm".

urlThisDoc = WebWindow.ActivePageWindow.Document.Url
fileName = WebWindow.ActivePageWindow.Caption

You can also return the Caption property from the WebWindow object. In this case the text that is returned reflects the text in the title bar of the FrontPage application window, which consists of the application name and the URL of the specified WebWindow object, such as "Microsoft FrontPage – C:\MyWebs\Adventure Works". The following statement returns the value of the Caption property of the WebWindow object.

thisCaption = WebWindow.Caption

Use the Close method to close a WebWindow object. The following statement closes the specified WebWindow.

Set myWebWindowOne = WebWindows(0)
myWebWindowOne.Close

You can use the SelectedFiles and SelectedFolders properties to access selected objects within a WebWindow object. The following example returns the file names of selected files in each open web window.

Note To run this example, create a form with a command button called cmdSelectedFiles and a text box called txtSelFileDisplay. You must have more than one open web window with a selected file in each web window.

Private Sub cmdSelectedFiles_Click()
Dim myWebWindows As WebWindows
Dim myWebWindow As WebWindow
Dim mySelFiles As Variant
Dim mySelFile As WebFile
Dim mySelName As String
Dim myCount As Integer

Set myWebWindows = WebWindows

txtSelFileDisplay.maxLength = 1000
txtSelFileDisplay.MultiLine = True
txtSelFileDisplay.WordWrap = True
mySelName = "Selected Files: "

For Each myWebWindow In myWebWindows
    mySelFiles = myWebWindow.SelectedFiles
    For myCount = 0 To UBound(mySelFiles)
        Set mySelFile = mySelFiles(myCount)
        mySelName = mySelName & " " & mySelFile.Name
        txtSelFileDisplay.Text = mySelName & vbCrLf
    Next
Next
End Sub

Use the ViewMode property to return or set one of the values shown in the following table. You can also use these enumerated values to switch views in FrontPage.

Enumermated Constant | Value | Corresponding View in FrontPage
FpWebViewLinks | 0 | Hyperlinks view
FpWebViewFolders | 1 | Folders view
FpWebViewStructure | 2 | Navigation view
FpWebViewPage | 3 | Page view
fpWebViewAllFiles | 4 | View a list of every file in Reports view
FpWebViewTodo | 5 | View a To Do list in Tasks view
FpWebViewBrokenLinks | 6 | View a list of broken hyperlinks in Reports view
FpWebFiewSiteSummary | 7 | Site Summary view in Reports view

The following statement sets the ViewMode property to fpWebViewPage.

WebWindows(0).ViewMode = fpWebViewPage

Use the Visible property to return or set a boolean value for the state of a WebWindow object. The Visible property returns True if a WebWindow object is visible. The following statement sets a WebWindow object to an invisible state.

WebWindow.Visible = False

Use the Web property to return information about the Web object. The following statement returns the number of properties for the specified web.

myProperties = ActiveWeb.WebWindows(0).Web.Properties.Count


WebWindows Collection Object

WebWindows collection (WebWindow)

A collection of WebWindow objects. Each WebWindow object represents an open window in Microsoft FrontPage. The WebWindow object is a member of the WebWindows collection.

Using the WebWindows Collection

Use Items(index), where index is the index number of an item in the WebWindows collection, to return a single WebWindow object. The following example returns the Caption property for the fourth item in the WebWindows collection.

Function ReturnWebWindowCaption() As String
Dim myCaption As String
Dim myWebWindow As WebWindow

Set myWebWindow = Application.WebWindows(3)
myCaption = myWebWindow.Caption
ReturnWebWindowCaption = myCaption
End Sub

Use the WebWindows property to return the WebWindows collection. The following example closes all of the open WebWindow objects in the WebWindows collection, except the ActiveWebWindow object.

Private Sub CloseWebWindows
Dim myWebWindows As WebWindows
Dim myWebWindow As WebWindow
Dim myActiveWebWindow As WebWindow

Set myWebWindows = Application.WebWindows
Set myActiveWebWindow = ActiveWebWindow

For Each myWebWindow In myWebWindows
    If myWebWindow.Caption <> myActiveWebWindow.Caption Then _
        myWebWindow.Close
Next
End Sub

Use the Application property to return the Application object. If you're already working with the WebWindows collection and you'd like to check the version number of the application, you can easily access it from within your With myWebWindows statement as shown in the following example.

With myWebWindows
    myWebWindowCount = myWebWindows.Count
    myAppVersion = .Application.Version
    If myAppVersion < "4.0" Then
        MsgBox "Please upgrade your FrontPage software."
    Else
        For Each myWebWindow In myWebWindows
            myCaption = myWebWindow.Caption
            With myPageWindows
                myPageCount = PageWindows.Count
            End With
        Next
    End If
End With

You can use the Close method to close an individual WebWindow object, multiple WebWindow objects, or all WebWindow objects in a web. For more details on the Close method, see the usage described in the following table.

Important FrontPage will close the application if you use the Close method to close all WebWindow objects in FrontPage.

Close Method Usage | Code
Close an individual WebWindow object in the application
Application.WebWindows(index).Close

or
Application.WebWindows.Close(index)
Close multiple WebWindow objects in the application (as shown in the previous example)
For Each myWebWindow In myWebWindows

    If myWebWindow.Caption <> _
        myActiveWebWindow.Caption Then _
        myWebWindow.Close
Next
Close all WebWindow objects in the application
Application.WebWindows.Close
Close an individual WebWindow object in a web
Webs(index).WebWindows(index).Close
Close multiple WebWindow objects in a web
Set myWeb = Web(index).WebWindows

For Each myWebWindow In myWebWindows
    If myWebWindow.Caption _
      <> myActiveWebWindow.Caption Then _
        myWebWindow.Close
Next
Close a collection in a web
Webs(index).WebWindows.Close
Closing all WebWindow objects in FrontPage functions the same as the Quit method | The expression, Application.WebWindows.Close is the same as, Application.Quit.

Use the Count property to return the number of WebWindow objects in the collection. The following example returns the number of WebWindow objects.

Web.WebWindows.Count

Use the Parent property when you want to return the container for the WebWindows collection. The following statement returns the Application object.

Application.WebWindows.Parent.Name


ActiveDocument Property

Returns the active document as an IHTML Document2 object. Read-only Application or PageWindow object.

Remarks

This object provides access to the Microsoft FrontPage Page object model elements that are compatible with Microsoft Internet Explorer 4.0 and later. This object model provides programmatic capability for the HTML and DHTML programming elements of Internet Explorer.


ActiveDocument Property Example

The following statement returns the ActiveDocument object for the Application object.

myDoc = Application.ActiveDocument

The following statement returns the ActiveDocument object for the PageWindow object.

myDoc = Application.WebWindows(0).PageWindows(0).ActiveDocument


ActiveFrameWindow Property

Returns the IHTMLWindow2 PageWindow object of the selected frame in the page window. Read-only Object.

Note Accessing the ActiveFrameWindow property is the same as accessing the parent window throught the active page window as follows:

ActivePageWindow.Document.parentWindow


ActiveFrameWindow Property Example

This example retrieves the ActiveFrameWindow object.

Private Sub GetActiveFrame()
Dim myPageWindow As PageWindow
Dim myFrame As FPHTMLWindow2

Set myPageWindow = _
    ActiveWeb.ActiveWebWindow.ActivePageWindow
Set myFrame = myPageWindow.ActiveFrameWindow
End Sub


ActivePageWindow Property

Returns the ActivePageWindow object. Read-only Application or WebWindow.


ActivePageWindow Property Example

The following example returns the ActivePageWindow object for the Application object.

Private Sub GetActivePageWindow()
Dim myPageWindow As PageWindow

Set myPageWindow = ActivePageWindow
End Sub

The following example returns the ActivePageWindow object from within the WebWindow object.

Private Sub GetActivePageWindow()
Dim myPage As PageWindow

Set myPage = ActiveWebWindow.ActivePageWindow
End Sub


ActiveWeb Property

Returns the current ActiveWeb object. Read-only Object.

Remarks

The Microsoft FrontPage Application object model provides access to the Web object model through the ActiveWeb object. For more information about the FrontPage object models, see Exploring the Object Model in FrontPage.


ActiveWebWindow Property

Returns the current ActiveWebWindow for the specified object. Read-only Object.


ActiveWebWindow Property Example

This example prints the value of the ActiveDocument.nameProp property for the ActiveWebWindow object.

Note To run this example, create a form with a command button called cmdActiveWebWindowDisplay and a label called lblWebWindowDisplay. Paste the following code in the code window. You must have a FrontPage-based web page open for this procedure to return a document name.

Private Sub cmdActiveWebWindowDisplay_Click()
On Error Resume Next
Dim myCurrentWebWindow As WebWindow

Set myCurrentWebWindow = Application.ActiveWebWindow

With myCurrentWebWindow
    lblWebWindowDisplay.Caption = .ActiveDocument.nameProp
End With
End Sub


AllowsLongFilenames Property

True if the operating system on the machine where the web resides accepts long file names. Read-only Boolean.


AllowsLongFilenames Property Example

This example checks the value of the AllowsLongFilenames property of the ActiveWeb object. This example assumes that ConvertLongFilenames is a procedure that is available to this code sample.

If ActiveWeb.AllowsLongFilenames = True Then
    Exit Sub
Else
    Call ConvertLongFilenames()
End If


AnswerWizard Property

Returns the AnswerWizard object. Read-only AnswerWizard.


AnswerWizard Property Example

This example adds an Answer Wizard file, and retrieves the Creator and Count properties.

Note The Creator property for FrontPage is different from the Creator property used by other Microsoft Office objects, such as the AnswerWizard object. The Creator property for FrontPage uses a string format, while Office objects use a 32-bit integer to identify the application that created the file. In this example, you'll note that the Creator property returns a 32-bit integer rather than the FrontPage string format because the AnswerWizard object is an Office ImsoDispObj object. For more information, use the Object Browser for all libraries or Microsoft Visual Basic Help to view more detailed information about the Creator property for Microsoft Office objects.

Private Sub GetAnswerWizardInfo()
Dim myAW As AnswerWizard
Dim myAWFiles As AnswerWizardFiles
Dim myAWCount As Integer
Dim myAWCreator As String

Set myAW = activeWeb.Application.AnwerWizard
Set myAW = myAW.Files

With myAWFiles
    myAWCreator = .Creator
    .Add ("myAWFile")
    myAWCount = .Count
End With
End Sub


Application Property

Returns the Application object. Read-only Object.

Remarks

Used without a qualifier, this property provides direct access to the Microsoft FrontPage Application object. Used with an object qualifier, this property returns an Application object that represents the creator of the specified object—you can use this property with an Automation object to return that object's application.


Application Property Example

The application name can be directly accessed from the objects and collections in the FrontPage object model. This statement shows the application accessed from within the Files collection.

Set currApp = ActiveWeb.RootFolder.Files.Application


Build Property

Returns the build number for the specified object. Read-only String.

Remarks

If the Application object is specified, the Build property returns the build number of the application. When the System object is specified, this property returns the build number of the operating system. For example, the format used on the About dialog box for an application might look like this: “Version: 4.0.0.xxxx,” where xxxx is the build number of the application. When the Build property for the System object is accessed, it returns the current build of the operating system as you might see used on the Properties page of the System dialog box.


Build Property Example

The following statement returns the build number of the application.

myAppBuild = Application.Build

You can access the system build as shown in the following statement.

mySysbuild = System.Build


Caption Property

Returns the text of the title bar for the specified object. Read-only Object.

Remarks

The Caption property returns different values depending on the specified object. For example, the Caption property for the PageWindow object returns the file URL of the open page, while the Caption property for the WebWindow object returns the text of the title bar for the Microsoft FrontPage application window.


Caption Property Example

This statement returns the caption of the active page.

myCaption = ActivePageWindow.Caption

This example demonstrates accessing both the active WebWindow and PageWindow objects using the With and For statements.

Private Sub GetPageWindowCaption()
Dim myWebWindow As WebWindow
Dim myPageWindows As PageWindows
Dim myPageWindowCaptions As String
Dim myWebWindowCaption As String

Set myWebWindow = Application.ActiveWebWindow
Set myPageWindows = myWebWindow.PageWindows

With myWebWindow
    myWebWindowCaption = .Caption
End With

For Each myPageWindow in myPageWindows
    myPageWindowCaptions = myPageWindowCaption & myPageWindow.Caption
Next
End Sub


CheckedoutBy Property

Returns the logon name of the person to whom the specified WebFile object is checked out. Read-only WebFile.

Note You must have a source control project in place before using this method.


CheckoutedBy Property Example

CheckedoutBy Property Example

This example retrieves the logon alias of the person who checked out the file.

Note You must have a source control project to run this example.

Private Sub GetCheckedOutBy()
Dim myCheckedOutAlias As String

myCheckedOutAlias = _
    ActiveWeb.RootFolder.Files(0).CheckedOutBy
End Sub


Children Property

Returns the collection of child navigation nodes for a navigation node. Read-only Object.


Children Property Example

This example returns the number of child nodes that exist directly below the home page navigation node.

Private Sub GetChildrenCount()
Dim myCount As Integer

myCount = ActiveWeb.HomeNavigationNode.Children.Count
End Sub


COMAddIns Property

Returns the COMAddIns object. Read-only Object.

Remarks

All of the FrontPage add-ins that are registered in the Windows Registry are located under the following key:

HKey_Current_User\Software\Microsoft\Office\FrontPage\AddIns

Add-ins designed for administrators are registered under:

HKey_Local_Machine\Software\Microsoft\Office\FrontPage\Addins


COMAddIns Property Example

This example returns the number of add-ins available to Microsoft FrontPage.

Private Sub GetCOMAddIns()
Dim myWeb As Web
Dim myAddinCount As Integer

Set myWeb = ActiveWeb
myAddinCount = Application.COMAddIns.Count

End Sub


CommandBars Property

Returns a CommandBars object that represents the menu and toolbars displayed by Microsoft FrontPage. Read–only Object.

Remarks

You can't access FrontPage-specific popup context menus using command bars. For example, you can't access the context menu that appears when you right-click a page in Pages view. However, you can create your own popup context menus using the ShowPopup method for the CommandBar object.


CommandBars Property Example

The following three procedures set up a new menu item on a toolbar.

Procedure 1:

Sub AddMenuItem()
Dim newMenu As CommandBarControl
Dim toolsMenu As CommandBar
Set toolsMenu = Application.CommandBars("Tools")

Set newMenu = _
  toolsMenu.Controls.Add(msoControlButton, , , , True)

newMenu.Caption = "New &Menu Item"
End Sub

This next procedure connects the click event to the custom button and must be added to a class or form module. The module shown is a form module. This procedure adds a new item to the Tools menu and connects the events of the custom button by assigning the variable e_NewMenu (used in the WithEvents statement) to the custom button variable newMenu.

Procedure 2:

Private Sub AddButton_Click()
Dim newMenu As CommandBarControl
Dim WithEvents e_NewMenu As CommandBarButton

Sub AddMenuItemWithEventHook()
Dim toolsMenu As CommandBar
Set toolsMenu = Application.CommandBars("Tools")

Set newMenu = _
  toolsMenu.Controls.Add(msoControlButton, , , , True)

Set e_NewMenu = newMenu
newMenu.Caption = "New &Menu Item"
End Sub

Private Sub e_NewMenu_Click(ByVal Ctrl As _
  Office.CommandBarButton, CancelDefault As Boolean)
MsgBox "Menu Item Clicked"
ctrl.caption = "Clicked"
End Sub

To execute FrontPage custom menu items using CommandBars collection, index the menu item and call the execute method for that item. The following example inserts a Microsoft Office spreadsheet control at the insertion point.

Procedure 3:

Sub ExecuteMenu()
Dim I As String
Dim C As String
Dim O As String

I = "Insert"
C = "C&omponent"
O = "Office Sp&readsheet"

CommandBars(I).Controls(C).Controls(O).Execute
End Sub

The following example returns the status of various properties of the command bars in the active web.

Private Sub GetCommandBars()
Dim myWeb As Web
Dim myCB As Object
Dim myCBCount As Integer
Dim myDisplayFonts As Boolean
Dim myDisplayKeysInToolTips As Boolean
Dim myLargeButtons As Boolean
Dim myMenuAnimationStyle As String

Set myWeb = ActiveWeb
Set myCB = Application.CommandBars

With myCB
    myCBCount = .Count
    myDisplayFonts = .DisplayFonts
    myDisplayKeysInToolTips = .DisplayKeysInToolTips
    myLargeButtons = .LargeButtons
    myMenuAnimationStyle = .MenuAnimationStyle
End With
End Sub

The following example is a tool that iterates through the command bars and returns several properties from each menu.

Note To run this example, create a form that has a text box called txtComBar and a command button called cmdComBar, and copy the following code to the code window.

Private Sub cmdComBar_Click()
Dim myWeb As Web
Dim myComBars As Object
Dim myComBar As Object
Dim myText As String
Dim myName As String
Dim myAdaptMenu As String
Dim myEnabledMenu As String
Dim myMenuHeight As String
Dim myMenuWidth As String

Set myWeb = ActiveWeb
Set myComBars = Application.CommandBars
myName = "Name: "
myAdaptMenu = "Menu Adaptive? "
myEnabledMenu = "Menu Enabled? "
myMenuHeight = "Menu Height: "
myMenuWidth = "Menu Width: "
txtComBar.Locked = True
txtComBar.MaxLength = 10000
txtComBar.MultiLine = True
txtComBar.ScrollBars = fmScrollBarsVertical

With myComBars
    For Each myComBar In myComBars
        With myComBar
            myText = myText & myName & .Name & vbCrLf
             myText = myText & myAdaptMenu _
                 & .adaptivemenu & vbCrLf
            myText = _
                myText & myEnabledMenu & .Enabled _
                & vbCrLf
            myText = myText & myMenuHeight & .Height _
                & vbCrLf
            myText = myText & myMenuWidth & .Width _
                & vbCrLf
            txtComBar.Text = myText
        End With
    Next
txtComBar.SetFocus
txtComBar.CurLine = 0
End With
End Sub


Count Property

Returns the number of items in the specified collection. Read-only Variant.

Remarks

Some collections are 0-based and some are 1-based. The Count property for collections begins with one even though you'd access the first item in a collection with a zero.


Count Property Example

The following example returns the number of themes and folders in the active web.

Private Sub GetWebCount()
Dim myWeb As Web
Dim myCount As Integer

Set myWeb = ActiveWeb

With myWeb
    myThemeCount = .Themes.Count
    myFolderCount = .RootFolder.Folders.Count
End With
End Sub


Creator Property

Returns a string that indicates the application in which this object was created. If the object was created in Microsoft FrontPage, this property returns the string "FrontPage.Editor.Document". Read-only String.

Note The Creator property for FrontPage is different from the Creator property used by other Microsoft Office objects. The Creator property for FrontPage uses a string format, while Office objects use a 32-bit integer to identify the application that created the file.


Creator Property Example

This example checks if the creator of a file is FrontPage.

Private Sub GetCreator()
Dim myCreator As String

myCreator = ActiveWeb.RootFolder.Files(0).Creator

If myCreator <> "FrontPage.Editor.Document" Then
    MsgBox "This file was not created by FrontPage."
End If
End Sub


Document Property

Returns the IHTMLDocument2 object. Read-only Object.

Remarks

The Document property provides access to the Page object model in Microsoft FrontPage that is compatible with Internet Explorer 4.0 and later. For more information on the Page object model, see Exploring the Object Model in FrontPage.


Document Property Example

This example opens a page and uses the insertAdjacentText method to add text to the document.

Note To run this example, you must have a web called "C:\My Documents\My Webs\Rogue Cellars" (for a server running on Microsoft Windows) or "C:\WINNT\Profiles\logon alias\Personal\My Webs\Rogue Cellars" (for a server running on Windows NT). In either case, you may substitute an alternative web URL or file. You must also have a file named Sales.htm or substitute an alternative file.

Private Sub AddTextToDoc()
Dim myWeb As Web
Dim myPageWindow As PageWindow
Dim myText As String

Set myWeb = _
    Webs.Open("C:\My Documents\My Webs\Rogue Cellars")
myWeb.Activate
myText = "Winter Sale Begins November 1st!"
Set myPageWindow = _
    ActiveWeb.RootFolder.Files("Sales.htm").Edit

myPageWindow.Document.body.insertAdjacentText _
    "BeforeEnd", myText

ActivePageWindow.Save
ActiveWeb.Close
End Sub


Extension Property

Returns the extension for the specified file. Read-only String.


Extension Property Example

This statement returns the extension of the home page.

myHomePageExt = ActiveWeb.RootFolder.File(0).Extension


File Property

Returns the WebFile object associated with the specified object. Read-only Object.


Files Property

Returns the items in the WebFiles collection. Read-only Object.

Remarks

The Files property is a pointer to the WebFiles collection. To access the collection, declare a variable of type WebFiles as shown in the statement, Dim myFiles As WebFiles, and then set the variable myFiles to Web.RootFolder.Files.


FileSearch Property

Returns the msoFileSearch object. Read-only FileSearch.

Remarks

The FileSearch object does not accept a uniform resource locator (URL) as a file name or folder name value.


FileSearch Property Example

This example searches the Adventure Works web and its subdirectories and returns the number of Index.htm files found in the web.

Note To run this example, you must have a web called "C:\My Documents\My Webs\Adventure Works" (for a server running on Microsoft Windows) or "C:\WINNT\Profiles\logon alias\Personal\My Webs\Adventure Works" (for a server running on Windows NT). As an alternative, you can change the value for LookIn to a web that is currently available to you. You must also set a reference to Microsoft Office 9.0 Object Library.

Private Sub WebFileSearch()
Dim myFileSearch As FileSearch
Dim myFileCount As Integer

Set myFileSearch = Application.FileSearch

With myFileSearch
    .FileName = "index.htm"
    .LookIn = "C:\My Webs\Adventure Works"
    .SearchSubFolders = True
    .Execute
    myFileCount = .FoundFiles.Count
End With
End Sub


Folders Property

Returns the items in the WebFolders collection. Read-only Object.

Remarks

The Folders property returns the WebFolders collection for the specified web. To access the collection, you declare a variable of type WebFolders as in the statement, Dim myFolders As WebFolders, and then set the variable to Web.RootFolder.Folders.


Folders Property Example

This example retrieves two of the properties of a folder and concatenates the data into a string with a pipe ("|") delimiter separating the data.

Note The PropertyKeys shown in this example apply to a web created with the One Page Only Web Wizard. Other templates may use other PropertyKeys.

Private Sub GetFolderProperties()
Dim myFolders As WebFolders
Dim myFolder As WebFolder
Dim myHasSubDirs As String
Dim myIsScriptable As String
Dim myProperties As Properties

Set myFolders = ActiveWeb.Rootfolder.Folders

For Each myFolder In myFolders
    Set myProperties = myFolder.Properties

    myHasSubDirs = myHasSubDirs & _
        myProperties("vti_ hassubdirs") & "|"
    myIsScriptable = myIsScriptable & _
        myProperties("vti_ isscriptable") & "|"
Next
End Sub


Format Property

Returns the format of the specified Theme object. Read-only String.

Remarks

The theme format reflects the difference between the formats for Microsoft FrontPage 98 and Microsoft FrontPage 2000. The format number for FrontPage 98 can be either 0.0 or 1.0, while the format number for FrontPage 2000 is 2.0.


Format Property Example

This example retrieves the format of the applied theme for the active web.

Private Sub GetThemeFormat()
Dim myFormat As String

myFormat = ActiveWeb.Themes(0).Format
End Sub


FrameWindow Property

Returns the FPHTMLWindow2 object. The Document property of the FPHTMLWindow2 object points to the FPHTMLDocument object of the frames page. Read-only Object.


FrameWindow Property Example

This example retrieves the IHTMLLocation property of the FrameWindow object.

Private Sub GetFrameWindowLocation()
Dim myWeb As Web
Dim myPage As PageWindow
Dim myFrameWindowLocation As String

Set myWeb = Webs("C:\My Webs\Rogue Cellars")
Set myPage = _
    myWeb.ActiveWebWindow.ActivePageWindow
myFrameWindowLocation = myPage.FrameWindow.Location.href
End Sub


Home Property

Returns the HomeNavigationNode object for the Navigation object. Read-only Object.


HomeNavigationNode Property

Returns the navigation node for the home page. Read-only Object.

Remarks

The home navigation node is the starting point for all navigation addressing within the navigation structure. Whenever you want to add, move, or delete a node, change any of the attributes for a node, or just access the current navigation structure, you use the HomeNavigationNode object as a starting point. The only time you would use the RootNavigationNode object to access the navigation structure is when you want to add or access a navigation node at the same level as the HomeNavigationNode object.


HomeNavigationNode Property Example

This example accesses the HomeNavigationNode object and retrieves the URL for the home page.

Private Sub GetHomeNavigationNode()
Dim myWeb As Web
Dim myHomeNode As NavigationNode
Dim myHomeUrl As String

Set myWeb = ActiveWeb

myHomeNode = myWeb.HomeNavigationNode
myHomeURL = myHomeNode.Url
End Sub


HorizontalResolution Property

Returns the horizontal resolution of the screen in pixels. Read-only Long.


HorizontalResolution Property Example

This example returns the horizontal resolution of the screen.

myHoriz = System.HorizontalResolution


IsDirty Property

True if the PageWindow object has changed since the last time the object was saved. Read-only Long.


IsDirty Property Example

This example checks if the active page has changed; if it has, the program executes the Save method for the active page.

Private Sub DirtyDocument()
Dim myPage As PageWindow
Dim myDoc As FPHTMLDocument
Dim mySaveCheck As Boolean

Set myDoc = WebWindows(0).PageWindows(0).Document

Call myDoc.body.insertAdjacentHTML("BeforeEnd", _
    "<b> modified </b>")
If ActivePageWindow.IsDirty = True Then
    ActivePageWindow.Save
End If
End Sub


IsExecutable Property

Returns the setting for execute permission for a WebFolder object. Read/write Boolean.


IsExecutable Property Example

This example retrieves the setting of the IsExecutable property for a WebFolder object.

Private Sub CheckExecutable()
Dim myFolder As WebFolder
Dim myExeStatus As Boolean

Set myFolder = ActiveWeb.RootFolder.Folders("images")
myExeStatus = myFolder.IsExecutable

End Sub


IsOpen Property

True if the active WebFile object is open. Read-only Boolean.


IsOpen Property Example

This example uses the IsOpen property to check if a file is open.

Private Sub CheckForOpenFile()
Dim myWeb As Web
Dim myFiles As WebFiles
Dim myFile As WebFile
Dim myFileToOpen As String
Dim myMessage As String
Dim myFileName As String

Set myWeb = ActiveWeb
Set myFiles = myWeb.RootFolder.Files

myFileToOpen = "index.htm"
myMessage = "This file is open, try again later."

With myWeb
    For Each myFile In myFiles
        If myFileName = myFileToOpen Then
                If myFile.IsOpen = True Then
                MsgBox (myMessage)
                Exit Sub
            Else
                myFile.Open (fpPageViewNormal)
                Exit Sub
            End If
        End If
    Next
End With
End Sub


IsReadable Property

Returns the setting for read permission for a WebFolder object. Read/write Boolean.


IsReadable Property Example

This example retrieves the setting of the IsReadable property for a WebFolder object.

Private Sub CheckReadable()
Dim myFolder As WebFolder
Dim myReadStatus As Boolean

Set myFolder = ActiveWeb.RootFolder.Folders("images")
myReadStatus = myFolder.IsReadable

End Sub


IsRoot Property

Returns the setting for whether a WebFolder object is the root web. Read-only Boolean.


IsRoot Property Example

This example retrieves the setting of the IsRoot property for a WebFolder object.

Private Sub CheckExecutable()
Dim myFolder As WebFolder
Dim myIsRoot As Boolean

Set myFolder = ActiveWeb.RootFolder.Folders("images")
myIsRoot = myFolder.IsRoot

End Sub


IsUnderRevisionControl Property

True if source control is used on the active Web object. Read-only Boolean.

Remarks

You must have a source control project created through Microsoft Visual SourceSafe or Microsoft Office in order to use revision control.


IsUnderRevisionControl Property Example

This example creates a source control project and then, in the second procedure, checks the state of IsUnderRevisionControl property.

Private Sub SourceControlProject()
Dim myWeb As Web

Set myWeb = ActiveWeb

If Not (myWeb.IsUnderRevisionControl) Then
    myWeb.RevisionControlProject = _
        "<FrontPage-based Locking>"
End If
End Sub

Private Sub GetRevisionState()
Dim myWeb As Web
Dim myRevCtrlProj As String
Dim myIsRevCtrl As Boolean

Set myWeb = ActiveWeb

With myWeb
    myRevCtrlProj = .RevisionControlProject
    myIsUnderRevCtrl = .IsUnderRevisionControl
End With
End Sub


IsWeb Property

Returns the setting for whether a WebFolder object is a web. Read-only Boolean.


IsWeb Property Example

This example retrieves the setting of the IsWeb property for a WebFolder object.

Private Sub CheckExecutable()
Dim myFolder As WebFolder
Dim myWebStatus As Boolean

Set myFolder = ActiveWeb.RootFolder.Folders("images")
myWebStatus = myFolder.IsWeb

End Sub


IsWritable Property

Returns the setting for write permission for a WebFolder object. Read-only Boolean.


IsWritable Property Example

This example retrieves the setting of the IsWritable property for a WebFolder object.

Private Sub CheckExecutable()
Dim myFolder As WebFolder
Dim myWritableStatus As Boolean

Set myFolder = ActiveWeb.RootFolder.Folders("images")
myWritableStatus = myFolder.IsWritable

End Sub


Item Property

Returns a single object from a collection based on the value of the Index argument. Read-only String.

Syntax 1: Returns the PropertyKey for the specified MetaTags or Properties collections.

Syntax 2: Returns the index number for the specified object. Can be one of the following NavigationNodes, PageWindows, Themes, WebFiles, WebFolders, Webs, or WebWindows collections.

Syntax 1

expression.Item(PropertyKey As String)

expression An expression that returns a collection object.

PropertyKey Required String. A string that contains an index number of the collection. The index starts at zero.

Syntax 2

expression.Item(Index)

expression An expression that returns a collection object.

Index Required Variant. Refers to an item in the collection. Can be any number corresponding to an item in the collection, with the index starting at zero.


Item Property Example

The following example demonstrates returning a value by indexing an item in the collection. This example returns the label for the first navigation node in the navigation structure of the active web.

Note You access the NavigationNodes collection through the Children property of the RootNavigationNode property of the active web.

Private Sub GetNavigationNode()
Dim myWeb As Web
Dim myNavNodes As NavigationNodes
Dim myNavNodeLabel As String

Set myWeb = ActiveWeb

myNavNodeLabel _
    = myWeb.RootNavigationNode.Children.Item(0).Label
End Sub

Note You can also omit the Item property and access the specified item using the following coding method. The following statement returns the same value as the previous statement. For more information and another example of omitting the Item property, see the last paragraph in this section.

myNavNodeLabel _
    = myWeb.RootNavigationNode.Children(0).Label

The following statement returns the contents of a META tag that exists on a web page in the active web, and demonstrates the PropertyKey As String argument.

myMetaTagContents _
    = ActiveWeb.RootFolder.Files.Item(0).MetaTags.Item("generator")

Note On the HTML tab in Page view, FrontPage displays this meta tag as initially capped (Generator). However, the value of the meta tag item is all lowercase letters (generator). If you capitalize the first letter of a META tag name and use it as search criteria in a Visual Basic program, your search will fail.

It isn't always necessary to specify the index or property name of the Item property when returning values from a collection. The following example returns a list of file names of each web page that contains a META tag name equivalent to "generator" in the active web, without specifying the Item property. FindGeneratorTags retrieves a list of the files that contain the "generator" META tag and adds value of the Item property to the variable myMetaTag, because in this case the value of the Item property is the same as the file name. This is different from the previous example, which returned the contents of the "generator" META tag.

Private Function FindGeneratorTags() As String
Dim myWeb As Web
Dim myMetaTags As MetaTags
Dim myMetaTag As Variant
Dim myFiles As WebFiles
Dim myFile As WebFile
Dim myMetaTagName As String
Dim myReturnFileName As String

Set myWeb = ActiveWeb
Set myFiles = myWeb.RootFolder.Files

With myWeb
    For Each myFile In myFiles
        Set myMetaTags = myFile.MetaTags
        For Each myMetaTag In myMetaTags
            myMetaTagName = myMetaTag
            If myMetaTagName = "generator" Then
                myReturnFileName = myReturnFileName & myFile.Name
            End If
        Next
    Next
End With
FindGeneratorTags = myReturnFileName
End Function


Label Property

Returns the label associated with the active navigation node. This label is used as a reference for individual navigation nodes in Navigation view or as the name of a theme. Read/write String.

Remarks

Use the text in a Label object for the text in a banner or button that links to another navigation node in the navigation structure.


Label Property Example

This example sets the text for the label of the first child node. The label shows the placement of the node in Navigation view.

Private Sub AddLabelToNavigationNode()
Dim myNode As NavigationNode

Set myNode = ActiveWeb.HomeNavigationNode.Children(0)

myNewNode.Label = “Finance Page”
End Sub

This example retrieves the name of a theme.

Note To run this procedure, you must have an open web with a page that has previously had a theme applied to it.

Private Sub GetThemeName()
Dim myTheme As String

myTheme = ActiveWeb.Themes(0).Label
End Sub


LanguageDesignation Property

Returns the abbreviated name of the designated language of the system software. Read-only String.

Remarks

Using the two-letter language abbreviation from the ISO Standard 639 and adding a third letter, such as “u” for the United States, creates the three- letter abbreviation.

You can also get the two-letter language abbreviation with GetLocaleInfo() by specifying LOCALE_SABBREVLANGNAME as the LCType. The abbreviated name ”enu” is returned for the English (US) language and is the same abbreviation that is returned with the LanguageDesignation property.


LanguageDesignation Property Example

This example displays the abbreviated name of the designated language of the system software.

myLang = System.LanguageDesignation


LanguageSettings Property

Returns the LanguageSettings object for the Microsoft FrontPage application. Read-only LanguageSettings.


LanguageSettings Property Example

This example returns the LanguageID property for the user interface and sets the LanguagePreferredForEditing properties.

Note The LanguageSettings property has a required constant called MsoAppLanguageID. The enumerated values for this constant are msoLanguageIDHelp, msoLanguageIDInstall, msoLanguageIDUI, and msoLanguageIDUIPrevious. The LanguagePreferredForEditing property also has enumerated constants for the available languages. For more detailed information see the LanguageSettings object.

Private Sub GetLanguageInfo()
Dim myLSet As LanguageSettings
Dim myLangID As String
Dim prfLang As String

Set myLSet = Application.LanguageSettings

With myLSet
myLangID = .LanguageID(msoLanguageIDUI)
prfLang = _
.LanguagePreferredForEditing(msoLanguageIDEnglishUS) _
  = True
End With
End Sub


MetaTags Property

Returns the MetaTags collection for the specified WebFile object. Read-only MetaTags.


MetaTags Property Example

This example iterates through the META tags collection and concatenates the file names and META tag names into a string called myReturnInfo.

Private Sub GetMetaTagInfo_Click()
Dim myWeb As Web
Dim myFiles As WebFiles
Dim myFile As WebFile
Dim myMetaTags As MetaTags
Dim myMetaTag As Variant
Dim myFileName As String
Dim myMetaTagName As String
Dim myReturnInfo As String

Set myWeb = ActiveWeb
Set myFiles = myWeb.RootFolder.Files

With myWeb
    For Each myFile In myFiles
        Set myMetaTags = myFile.MetaTags
        For Each myMetaTag In myMetaTags
            myFileName = myFile.Name
            myMetaTagName = myMetaTag
            myReturnInfo = myFileName & ": " _
                & myMetaTagName
        Next
    Next
End With
End Sub


Name Property

Returns the string value of the name assigned to the specified object. Read-only String.

Remarks

The name of a file or folder is usually the last part of the URL. For example, is you have a URL such as, "C:\My Webs\Adventure Works\index.htm", the Name object of the file is "index.htm". Similarly, "Images" is the Name object for the folder of the URL, "C:\My Webs\Adventure Works\Images".


Name Property Example

The following statement returns the application name with AppName as the string variable.

AppName = Application.Name


NavigationNode Property

Returns the current NavigationNode object in the navigation structure for the WebFile object. Read-only Object.

Remarks

If a NavigationNode is not found within the current FrontPage-based web navigation structure, the NavigationNode property returns Null.


NavigationNode Property Example

This example uses the NavigationNode property to return the file name associated with the navigation node.

Private Sub GetNavNode()
Dim myWeb As Web
Dim myNavNode As NavigationNode
Dim myNavNodeLabel As String

Set myWeb = ActiveWeb
Set myNavNode = _
    myWeb.RootNavigationNode.Files(0).NavigationNode

With myNavNode
    myNavNodeLabel = .Label
End With
End Sub


Next Property

Returns the next navigation node in the navigation sequence. Read-only Object.

Remarks

Although the Next property is a member of the NavigationNode class, this property navigates within the Children collection of the specified NavigationNode object.

Note The Children collection does not wrap, so that code such as Children(Children.Count – 1).Next returns an "Object or With variable not set" error.


Next Property Example

This example moves the navigation pointer to the next node, unless the current node is the last node of the level in the navigation structure.

Private Sub MoveNext()
Dim theNode As NavigationNode
Dim theNextNode As NavigationNode
On Error Resume Next

Set theNode = ActiveWeb.HomeNavigationNode.Children(1)
Set theNextNode = theNode.Next

If Err <> 0 then
    MsgBox “End of the current navigation row”
End If
End Sub


OperatingSystem Property

Returns the name of the current operating system, for example, “Windows” or “Windows NT”. Read-only String.


OperatingSystem Property Example

The following example displays system information in a label on a form.

lblSystemInfo.Caption=System.OperatingSystem

This example prints the name of the current operating system in the Immediate window.

myOpSys = System.OperatingSystem


OrganizationName Property

Returns the name of the orgranization for the application. Read-only Object.

Note The name of the organization is usually set during the installation of an application or operating system.


OrganizationName Property Example

Instead of creating a company name variable for your Web page, you can use the organization name as shown in the following statement.

myCompanyName = Application.OrganizationName


PageWindows Property

Returns the specified PageWindow object. Read-only PageWindows object.


PageWindows Property Example

This example retrieves a page window that contains the page Spain.htm and sets the view mode to Preview.

Note To run this procedure, you must have an open web that contains an open page called Spain.htm, or substitute a file of your choice.

Private Sub SetPagePreview()
Dim myPage As PageWindow

Set myPage = ActiveWebWindow.PageWindows("Spain.htm")
myPage.ViewMode = fpPageViewPreview
End Sub


Parent Property

Returns the name of the Parent object for the specified object. Read-only Object.

Remarks

Specifying the Parent property of a WebFile object returns the WebFolder object. When an object is contained in a web, the Parent property returns the Web object. For example, if the Theme object is contained in a Web object called "Adventure Works Web", the Parent property returns "Adventure Works Web"; otherwise, for a theme referenced outside of a Web object, the Parent property returns the name of the Application object—in this example, it would return "Microsoft FrontPage". However, when the System object is specified from a client computer, the Parent property returns the Application object of the host, not the client.

The following table describes the values returned for the different object types.

Object | Description
MetaTags | Returns the WebFile object for the META tags.
NavigationNode | Returns the parent NavigationNode object, except in the case of the RootNavigationNode object whose parent is the Web.
NavigationNodes | Returns the parent NavigationNode object for the collection of navigation nodes based on the navigation structure.
PageWindow | Returns the WebWindow or Application object in which the page resides.
PageWindows | Returns the Application object that contains the collection.
Properties | Returns the Web, WebFile or WebFolder object from the META tag information.
System | Returns the Application object.
Theme | Returns the parent (Web or WebFile) object for the theme.
Themes | Returns the Web object that contains the collection.
Web | Returns the Application object.
WebFile | Returns the WebFolder object.
WebFiles | Returns the parent WebFolder object.
WebFolder | Returns either the parent WebFolder object (if it's a subfolder) or returns the Web object for the root folder.
WebFolders | Returns the WebFolder object that contains the collection.
Webs | Returns the Application object.
WebWindow | Returns the Application object that contains the specified object.
WebWindows | Returns the Application object that contains the collection.


Parent Property Example

In this example, myParent returns the file type and build of the parent application for the active FrontPage-based web.

Private Sub GetParentInfo()
Dim myWeb As Web
Dim myParent As String
Dim myParentBuild As String

Set myWeb = Application.ActiveWeb

With myWeb
    myParent = .Parent.FileSearch.FileType
    ParentBuild = .Parent.Build
End With
End Sub


Prev Property

Returns the previous navigation node in the navigation sequence. Read-only Object.


Prev Property Example

This example moves the navigation pointer to the previous node, unless the current node is the first node of the level in the navigation structure.

Private Sub MovePrev()
Dim theNode as NavigationNode
Dim thePrevNode as NavigationNode
On Error Resume Next

Set theNode = ActiveWeb.HomeNavigationNode.Children(1)
Set thePrevNode = theNode.Prev

If Err <> 0 Then
    MsgBox “The current navigation level starts here.”
End If
End Sub


ProductCode Property

Returns the globally unique identifier (GUID) for Microsoft FrontPage. Read-only String.


ProductCode Property Example

This statement returns the Product ID for FrontPage.

mySystem = Application.ProductCode


ProfileString Property

Returns or sets a value for an entry in the Microsoft Windows registry under the following subkey:

HKEY_CURRENT_USERS\Software\Microsoft\FrontPage\

Read/write String.

Syntax

expression.ProfileString(RegistrySection As String, RegistryKey As String)

expression Required. An expression that returns a System object.

RegistrySection Required String. A subkey below the "HKEY_CURRENT_USERS\Software\MicrosoftFrontPage\" subkey in the Windows registry.

RegistryKey Required String. The name of the entry in the subkey specified by szSection. For example, Software or Network in the Registry Editor are subkeys.


ProfileString Property Example

This example returns the value of the subkey, 0 (zero), in the Recently Used URLs entry.

Note To run this example, you must have recently opened a page that exists in one of your webs.

Private Sub GetRegRecentlyUsedInfo()
Dim mySecKey As String
Dim myRegKey As String
Dim myProfile As String

mySecKey = "HKEY_CURRENT_USER\Software"
mySecKey = mySecKey & _
    "\Microsoft\FrontPage\Editor\Recently Used URLs"
myRegKey = "0"

myProfile = System.ProfileString(mySecKey, myRegKey)
End Sub


Properties Property

Returns the Properties collection for the specified object. Read-only Properties object.


Properties Property Example

This example adds a new property and displays it on the active web page.

Note To run this example, you must have a web called "C:\My Documents\My Webs\Rogue Cellars" (for a server running on Microsoft Windows) or "C:\WINNT\Profiles\logon alias\Personal\My Webs\Rogue Cellars" (for a server running on Windows NT), and a file called "Zinfandel.htm". Or, you may substitute an alternative web URL or file.

Private Sub CopyrightAdd()
Dim myWeb As Web
Dim myCopyright As String

myCopyright = "Copyright 1999 by Rogue Cellars"
Set myWeb = Webs.Open("C:\My Documents\My Webs\Rogue Cellars")
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


RevisionControlProject Property

Returns or sets the RevisionControlProject property. Read/write String.

Remarks

A revision control project can either be a Visual SourceSafe project, or a FrontPage-based locking project. For a Visual SourceSafe control project, you must start your project with the string "$/"; for a FrontPage-based locking control project, you must set the RevisionControlProject property to "<FrontPage-based Locking>".

To remove a source control project, use the following statement to set the revision control project to an empty string.

Set RevisionControlProject = ""


RevisionControlProject Property Example

This example sets the RevisionControlProject property in a Microsoft Visual SourceSafe project.

Private Sub SetRevisionControlProjectName()
Dim myWeb As Web
Dim myRevisionControlProject As String

Set myWeb = ActiveWeb
myRevisionControlProject = _
    "$/Rogue Cellars/Rogue Cellars Update"

myWeb.RevisionControlProject = _
    myRevisionControlProject
End Sub


RootFolder Property

Returns a Folder object that represents the active Web object's root. Read-only Object.


RootFolder Property Example

The following statement returns the name of the root folder.

ActiveWeb.RootFolder.Name


RootNavigationNode Property

Returns a NavigationNode object that represents the abstract navigation root. Read-only Object.

Remarks

You can use the RootNavigationNode property to determine the root navigation node. The RootNavigationNode property returns the NavigationNode object from which you can access all other navigation nodes in a web. The RootNavigationNode object is created by default when you create a web and provides the basis for the navigation structure, which is accessed through the Children collection. The first child node of the navigation structure is the home page of the Web site.


RootNavigationNode Property Example

The following example adds a global navigation node to the right of the home navigation node.

Private Sub AddNode()
Dim myRNode As NavigationNode
Dim myPage As String

Set myRNode = ActiveWeb.RootNavigationNode
myPage = "http://myServer/myWeb/search.htm"

Call myRNode.Children.Add(myPage, "Search", _
    fpStructRightmostChild)
ActiveWeb.ApplyNavigationStructure
End Sub


SelectedFiles Property

Returns the selected files. Read-only WebFile object.

Remarks

You must have the Folders view open in the User Interface (UI) in order to select multiple files and you must use the right pane to select the files. You can select multiple files in a single web or in multiple webs from Folders view. If you must use Page view, you can only select one file per web from the left pane.

Tip You can use the fpWebViewFolders constant of the ViewMode property to set the view to the Folders view.


SelectedFiles Property Example

This example concatenates the names of the selected files into a variable called mySelName.

Note The delimiter used to separate the file names in the variable mySelName is a space.

Private Sub GetSelectedFileNames()
Dim myWebWindows As WebWindows
Dim myWebWindow As WebWindow
Dim mySelFiles As Variant
Dim mySelFile As WebFile
Dim mySelName As String
Dim myCount As Integer

Set myWebWindows = WebWindows

mySelFiles = ActiveWebwindow.SelectedFiles

For myCount = 0 To UBound(mySelFiles)
    Set mySelFile = mySelFiles(myCount)
    mySelName = mySelName & " " & mySelFile.Name
Next
End Sub


SelectedFolders Property

Returns the selected folders. Read-only WebFolder object.

Remarks

You must have the Folders view open in the User Interface (UI) in order to select multiple folders and you must use the right pane to select the folders. You can select multiple folders in a single web or in multiple webs from Folders view. If you must use Page view, you can only select one folder per web from the folders in the left pane.

Note If you're programmatically selecting folders, you can use the fpWebViewFolders constant of the ViewMode property to set the view to the Folders view.


SelectedFolders Property Example

This example concatenates the names of the selected folders into a variable called mySelName.

Note The delimiter used to separate the folder names in the variable mySelName is a space.

Private Sub GetSelectedFolderNames()
Dim myWebWindows As WebWindows
Dim myWebWindow As WebWindow
Dim mySelFolders As Variant
Dim mySelFolder As WebFolder
Dim mySelName As String
Dim myCount As Integer

Set myWebWindows = WebWindows

mySelFolders = ActiveWebwindow.SelectedFolders

For myCount = 0 To UBound(mySelFolders)
    Set mySelFolder = mySelFolders(myCount)
    mySelName = mySelName & " " & mySelFolder.Name
Next
End Sub


SharedBorders Property

True if any shared borders are in use for the Web or WebFile object. Read/write Variant.

Syntax

expression.SharedBorders([BorderIndex As FpSharedBorders])

expression Required. An expression that returns or sets a shared border on a Web or WebFile object.

BorderIndex Optional FpSharedBorders. The border index is an enumerated type and can be one of the constants in the following table. The default constant is fpBorderTop.

FpSharedBorders | Value | Description
FpBorderTop | 1 | Sets or returns a border for the top of a page.
FpBorderLeft | 2 | Sets or returns a border for the left side of a page.
FpBorderRight | 4 | Sets or returns a border for the right side of a page.
FpBorderBottom | 8 | Sets or returns a border for the bottom of a page.
FpBorderAll | 255 or &HFF | Sets or returns borders on all sides of a page.

Remarks

Shared borders such as the constant, fpLeftBorder, can be used to set individual border values.

Note The default shared border is used if a shared border is not specified.


SharedBorders Property Example

This example sets the shared border for the active web.

Private Sub SetSharedBorders()
Dim myPage As PageWindow

ActiveWeb.SharedBorders(fpBorderLeft) = True

End Sub


System Property

Returns the System object. Read-only Object.


System Property Example

This statement returns the current operating system.

mySystem = Application.System.OperatingSystem


ThemeProperties Property

Returns or sets the Theme object for the specified object. Read/write Object.

Syntax

expression.ThemeProperties(PropertyIndex)

expression An expression that returns a PageWindow, Web, or WebFile object.

PropertyIndex Optional FpThemeProperties. Returns or sets the theme properties. Can be one of the following FpThemeProperties Type constants shown in the table. For more detailed information on the individual Type constants shown in the following table, see the tables and lists in the ApplyTheme method.

FpThemeProperties Type | Value | Description
fpThemeActiveGraphics | 16 or &H10 | Sets or returns the active graphics constant.
fpThemeBackgroundImage | 1 | Sets or returns a background image.
fpThemeCSS | 4096 or &H1000 | Sets or returns the cascading style sheet.
fpThemeDefaultSettings | 16777216 or &H1000000 | Returns the theme applied to the web.
fpThemeName | 33554432 or &H2000000 | Sets or returns the ThemeName constant.
fpThemeNoBackgroundImage | 0 | Sets or returns a background without an image.
fpThemeNoCSS | 0 | Sets or returns this property if a cascading style sheet has not been set or is not wanted.
fpThemeNormalColors | 0 | Sets or returns the color mode for normal color.
fpThemeNormalGraphics | 0 | Sets or returns the graphics mode for normal graphics.
fpThemePropertiesAll | 4369 or &H1111 | Sets or returns all of the theme properties. After a theme is applied to an object, the fpThemePropertiesAll property combines all of the properties applied to the object.
fpThemePropertiesNone | 0 | Sets or returns none for the theme properties.
fpThemeVivdColors | 256 | Sets or returns the vivid colors property.


ThemeProperties Property Example

The following example checks the theme properties for active graphics. If active graphics have been applied, then vivid colors are applied in addition to the theme properties that are already applied to the active page window. If active graphics aren't applied, then active graphics and vivid colors are both applied to the active page window.

Private Sub GetThemeProperties()
Dim myPageWindow As PageWindow

Set myPageWindow = ActiveWeb.ActiveWebWindow.ActivePageWindow

If myPageWindow.ThemeProperties(fpThemeActiveGraphics) Then
    myPageWindow.AppyTheme (fpThemePropertiesAll + _
        fpThemeVividColors)
    Exit Sub
Else
    myPageWindow.ApplyTheme (fpThemePropertiesAll + _
        fpThemeActiveGraphics + fpThemeVividColors)
End If
End Sub

The following example adds a background picture to the specified file.

Private Sub AddBackgroundImage()
Dim myFile As WebFile

Set myFile = Webs(0).Rootfolder.Files("index.htm")
If myFile.ThemeProperties(fpThemeBackgroundImage) = 0 Then
    myFile.ApplyTheme myFile.ThemeProperties(fpThemeName), _
        myfile.ThemeProperties(fpThemePropertiesAll) + _
        fpThemeBackgroundImage
End If
End Sub


Themes Property

Returns the collection of themes available for the specified object. Read-only Object.

Remarks

The Themes property as applied to the Application object returns the collection of themes available to be applied. When the Themes property is applied to the Web object, it returns the collection of themes that have been applied to the web. This is the same as the list that appears in the web’s _theme directory. If a theme is applied to a Web object, there will be one theme in the collection. However, if a page in a web has its own theme, separate from the theme that was applied to the web, then the Themes collection for the Web object will have two themes in it—the theme that was originally applied to the web, and the theme that was applied specifically to the page.


Themes Property Example

This example searches for a specific theme among the themes that are available locally on the client, as well as the themes applied to the ActiveWeb object.

Private Sub SearchAllThemes()
Dim myTheme As Theme
Dim myThemeToFind As String
Dim myIsFound As Boolean

myThemeToFind = “blends”
myIsFound = False

For Each myTheme In Application.Themes
    If myTheme.Label = myThemeToFind Then
        myIsFound = True
        Exit For
    End If
Next

For Each myTheme In ActiveWeb.Themes
    If myTheme.Label = myThemeToFind Then
        myIsFound = True
        Exit For
    End If
Next

End Sub


Title Property

Returns the title of the specified object. Read-only or read/write String depending on the specified object.

Remarks

For the Web and WebFile objects the Title property returns the title of the active Web object as a read/write String.


Title Property Example

At the same time as you're traversing the navigation nodes, you can also return the title (file name) of the file that's associated with a particular node. The following example returns the title of the file associated with a navigation node in the active FrontPage-based web.

Private Sub GetFileFromNavNode()
Dim myWeb As Web
Dim myNavNode As NavigationNode
Dim myFileFromNavNode As String

Set myWeb = ActiveWeb
Set myNavNode = _
    myWeb.RootNavigationNode.File.NavigationNode

With myNavNode
    myFileFromNavNode = .File.Title
End With
End Sub

The following example shows how you can set the title of the first file in the web.

Private Sub SetTitle()
Dim myWeb As Web
Dim myNewTitle As String
Dim myFile As WebFile

MyNewTitle = "Inventory.htm"
Set myWeb = ActiveWeb
Set myFile = myWeb.RootFolder.Files(0)

MyFile.Title = myNewTitle
End Sub


Url Property

Returns the URL for the specified object. Read-only String.

Remarks

URLs can be absolute or relative. An absolute URL contains the exact path to the specified object while a relative URL may contain characters such as "../..", "?", or ";" depending on the URL access scheme used to parse the relative URL. The Microsoft FrontPage object model always uses absolute URLs. For more information on URLs, see Understanding Absolute and Relative URLs in FrontPage 2000.


Url Property Example

This example returns the URL of the first file in the root folder of the active web.

Private Sub GetFileUrl()
Dim myFile As WebFile
Dim myURL As String

Set myFile = ActiveWeb.RootFolder.Files(0)
myURL = myFile.Url

End Sub


UserName Property

Returns the logon name of the user that is currently logged on to the network or operating system. Read/write String.

Remarks

The UserName property is the default parameter whenever a user name is required for a parameter in the Web object model. For example, the Webs.Open and Webs.Publish methods both require a UserName parameter. When the parameter isn't specified, the default parameter is the user name of the user currently logged on.


UserName Property Example

This example returns the current user's logon name.

myLogonName = Application.UserName


Version Property

Returns the version of the specified object with the format: "x.x.x", where x represents a number in the version. Read-only String.

Remarks

If the Application object is specified, the Version property returns the version of the application. When the Version property for the System object is accessed, it returns the current version of the operating system as you might see used on the Properties page of the System dialog box.


Version Property Example

The following example returns the version of the application.

Public Sub GetAppVersion()
Dim myAppVersion As String

myAppVersion = Application.Version
End Sub


VerticalResolution Property

Returns the vertical resolution of the screen in pixels. Read-only Long.


VerticalResolution Property Example

This example returns the vertical resolution of the screen.

myVerticalRes = System.VerticalResolution


ViewMode Property

Returns or sets the ViewMode object in Microsoft FrontPage. Read/write Long.

Note The write capability of the view mode is limited. For example, you can't set the view mode of an existing page window to fpPageViewNoWindow. However, you can open a page window with the FpPageViewMode argument set to fpPageViewNoWindow. Once you've opened a page in a windowless environment, you cannot set the FpPageViewMode argument to a different constant.

.Syntax 1: Returns or sets a PageWindow object.

Syntax 2: Returns or sets a WebWindow object.

Syntax 1

expression.ViewMode As FpPageViewMode

expression Required. An expression that returns or sets a ViewMode object for a PageWindow object.

FpPageViewMode A string that contains the view mode. It can be set to view modes such as Normal, HTML, or Preview, which correspond to tab names in Page view.

The following table describes the enumerated constants for the ViewMode property.

Enumerated Constant | Value | Description
FpPageViewDefault | 0 | The Normal tab in Page view for HTML pages and HTML tab in Page view for style sheets or .asp pages if they contain HTML that FrontPage cannot safely parse.
fpPageViewNormal | 1 | The Normal tab in Page view
fpPageViewHtml | 2 | The HTML tab in Page view
fpPageViewNoFrames | 4 | The NoFrames tab in Page view (this tab only appears when frames are present)
fpPageViewPreview | 8 | The Preview tab in Page view
fpPageViewNoWindow | 128 or &H80 | This setting prevents a window from opening for the page

Note Opening a page with fpPageViewNoWindow causes a condition where you can't access Window elements. For example, if you open a page without a window and try to access it using code such as PageWindow.Document.ParentWindow, the resulting code would return nothing instead of returning an FPHTMLWindow2 object. For more information on opening pages without Windows, see Coding in a Windowless Environment.

Syntax 2

expression.ViewMode As FpWebViewMode

expression Required. An expression that returns or sets a ViewMode object for a WebWindow object.

FpWebViewMode A string that contains the view mode. It can be set to Normal, HTML, or Preview, which correspond to tab names in Page view.

The following table describes the constants enumerated for the ViewMode property.

Enumerated Constant | Value | Description
fpWebViewLinks | 0 | Hyperlinks view
fpWebViewFolders | 1 | Folders view
fpWebViewStructure | 2 | Navigation view
fpWebViewPage | 3 | Page view
fpWebViewAllFiles | 4 | All files as viewed in the Reports view
fpWebViewTodo | 5 | To Do list in Tasks view
fpWebViewBrokenLinks | 6 | Broken Links list in Reports view
fpWebViewSiteSummary | 7 | Site Summary list in Reports view


ViewMode Property Example

This example changes the view of an open page window to HTML view.

Private Sub Get PageWindow()
Dim myPageWindow As PageWindow

Set myPageWindow = ActiveWebWindow.Pagewindows(0)
myPageWindow.ViewMode = fpPageViewHtml

End Sub


Visible Property

Returns or sets the visible state of the PageWindow or WebWindow object, depending on the object. The visible state for PageWindow object is read-only Boolean. The visible state for the WebWindow object is read/write Boolean.


Visible Property Example

The GetVisibleState procedure returns the visible state of the first PageWindow object from the CheckIfVisible function.

Private Sub GetVisibleState()
Dim myIsVisible As Boolean

myIsVisible = CheckIfVisible
End Sub

Function CheckIfVisible() As Boolean
Dim myPage As PageWindow
Dim myVisibleState As Boolean

Set myPage = Application.Webs(0).WebWindows(0).PageWindows(0)

myVisibleState = myPage.Visible
CheckIfVisible = myVisibleState
End Function

This example sets the visible state of a WebWindow object to a windowless state.

Private Sub OpenInNoWindow()
Dim myWebWindow As WebWindow

Set myWebWindow = Webs(0).WebWindows(0)

myWebWindow.Visible = False
End Sub


Web Property

Returns the Microsoft FrontPage-based web container for the specified object. Read-only Object.


Webs Property

Returns the collection of open webs for the specified object. Read-only Object.


Webs Property Example

This example creates an array that contains all of the URLs for all the open webs on your Web site.

Note You must open any webs for which you wish to retrieve the URLs.

Private Sub GetWebs()
Dim myWebs As Webs
Dim myWeb As Web
Dim myOpenWebs() As Variant
Dim i As Integer
Dim myWebCount As Integer

Set myWebs = Application.Webs
myWebCount = myWebs.Count

ReDim myOpenWebs(myWebCount)

Do
For Each myWeb In myWebs
    myOpenWebs(i) = myWeb.Url
    i = i + 1
Next
Loop Until i > myWebCount

End Sub


WebWindows Property

Returns the collection of open WebWindow objects in the specified object. Read-only Object.


WebWindows Property Example

This example checks if any of the web windows are set to Page view, and changes those that are in Page view to Folders view.

Private Sub GetViewModes()
Dim myWebWindows As WebWindows
Dim myWebWindow As WebWindow
Dim myView As FpWebViewMode

Set myWebs = Webs
Set myWebWindows = myWebs.WebWindows

For Each myWebWindow In myWebWindows
    myView = myWebWindow.ViewMode
    If myView = fpWebViewPage Then
        myWebWindow.ViewMode = fpWebViewFolders
    End If
Next
End Sub


Returning an Object from a Collection

The Item property returns a single object from a collection. The following statements set the fileOne variable to a WebFile object that represents the first file in the Files collection.

Dim fileOne As WebFile

Set fileOne = ActiveWeb.RootFolder.Files.Item(0)

The Item property is the default property for most collections, so you can omit the Item keyword as shown in the following statement.

Set fileOne = ActiveWeb.RootFolder.Files(0)

Named Objects

Although you can usually specify an integer value with the Item property, it may be more convenient to return an object by name. The following example edits a file named Web Sales.htm to the active web.

ActiveWeb.RootFolder.Files("Web Sales.htm").Edit


Help Topic Not Available

The Help topic cannot be displayed because Microsoft Office Visual Basic Help cannot be found, was not installed, or was removed.

To install Microsoft Office Visual Basic Help

  1. In Control Panel, double-click Add/Remove Programs.

  2. On the Install/Uninstall tab, click Microsoft Office 2000, and then click Add/Remove.

  3. Click Add or Remove Features, and then expand Office Tools and Visual Basic Help in the list of features.

  4. Click the icon next to Visual Basic Help to view the installation choices.

  5. Click Run from My Computer or Run from Network, and then click Update Now.


Help Topic Not Available

The Help topic cannot be displayed because Visual Basic for Applications Help cannot be found, was not installed, or was removed.

To install Visual Basic for Applications Help

  1. In Control Panel, double-click Add/Remove Programs.

  2. On the Install/Uninstall tab, click the edition of Microsoft Office 2000 that's installed, and then click Add/Remove.

  3. Click Add or Remove Features, and then expand Office Tools in the list of features.

  4. Click the icon next to Visual Basic Help to view the installation choices.

  5. Click Run from My Computer or Run from Network, and then click Update Now.


Save Method Example

This example creates a property, adds it to a file, and then saves the active page window. The ForceOverwrite argument set to True by default.

Note To run this example, you must have a web called "C:\My Documents\My Webs\Rogue Cellars" (for a server running on Microsoft Windows) or "C:\WINNT\Profiles\logon alias\My Webs\Rogue Cellars" (for a server running on Windows NT), or you may substitute an alternative web URL and file.

Private Sub AddSaleText()
Dim myWeb As Web
Dim myFile As WebFile
Dim mySaleProp As String
Dim mySaleText As String

mySaleText = "Vintage Wines for Oktoberfest Sale!!!"
Set myWeb = Webs.Open("C:\My Documents\My Webs\Rogue Cellars")
Set myFile = ActiveWeb.RootFolder.Files("Sale.htm")

myFile.Properties.Add "SaleText", mySaleText
mySaleProp = myFile.Properties("SaleText")
myFile.Open
ActiveDocument.body.insertAdjacentText "BeforeEnd", mySaleProp
ActivePageWindow.Save
WebWindows.Close
End Sub


ActiveWeb Property Example

This example uses the ActiveWeb property to locate the web page index.htm and changes the background color of the web page.

Note To run this example, create a form with one command button called cmdActiveWebColorChange and paste the following code in the code window. You must have a web page called index.htm for this procedure to change the background color.

Private Sub cmdActiveWebBKGRDColorChange_Click()
Dim myPageWin As PageWindow

Set myPageWin = Application.ActiveWeb.LocatePage("index.htm")

myPageWin.Document.bgColor = "PapayaWhip"

End Sub

Note Microsoft Visual Basic for Applications provides color constants with a "vb" prefix, such as vbCyan. FrontPage builds Web pages in HTML, which uses different color constants than Visual Basic. If you use the color constants provided with Visual Basic in your existing programs, you may need to change these to the equivalent hexadecimal color values when you port your programs to a FrontPage-based web, or when you use colors across Office applications that include a FrontPage-based web.


Files Property Example

This example retrieves all of the properties of a file and concatenates the META tags into a string with a pipe ("|") delimiter separating the data.

Note The PropertyKeys shown in this example apply to a web created with the One Page Only Web Wizard. Other templates may use other PropertyKeys.

Private Sub GetFileProperties()
Dim myFiles As WebFiles
Dim myFile As WebFile
Dim myAuthor As String
Dim myModifiedBy As String
Dim myTimeCreated As String
Dim myTimeLastModified As String
Dim myFileSize As String
Dim myTitle As String
Dim myMetaTags As Variant
Dim myMetaTag As Variant
Dim myProgID As Variant
Dim myGenerator As String
Dim myTimeLastWritten As String
Dim myProperties As Properties
Dim myMetaTagList As String

Set myFiles = ActiveWeb.Rootfolder.Files

For Each myFile In myFiles
    Set myProperties = myFile.Properties

    myAuthor = myAthor & myProperties("vti_author") _
        & "|"
    myModifiedBy = myModifiedBy & _
        myProperties("vti_modifiedby) & "|"
    myTimeCreated = myTimeCreated & _
        myProperties("vti_timecreated") & "|"
    myTimeLastModified = myTimeLastModified & _
        myProperties("vti_timelastmodified") & "|"
    myFileSize = myFileSize & _
        myProperties("vti_FileSize) & "|"
    myTitle = myTitle & myProperties("vti_title") _
        & "|"
    myProgID = myProgID & myProperties("vti_title") _
        & "|"
    myGenerator = myGenerator & _
        myProperties("vti_generator") & "|"
    myTimeLastWritten = myTimeLastWritten & _
        myProperties("vti_timelastwritten") & "|"
    myMetaTags = myProperties("vti_metatags")
    For Each myMetaTag In myMetaTags
        myMetaTagList = myMetaTagList & myMetaTag & "|"
    Next
Next
End Sub


File Property Example

This example returns the name of the File object associated with a navigation node in the active FrontPage-based web.

Private Sub GetFileFromNavNode()
Dim myNavNode As NavigationNode
Dim myNavNodes As NavigationNodes
Dim myNavFiles As String
Dim myNavFile As String
On Error Resume Next
Set myNavNodes = ActiveWeb.HomeNavigationNode.Children
For Each myNavNode In myNavNodes
    myNavFile = myNavNode.File.Name
    If Err <> 0 Then Exit Sub
    myNavFiles = myNavFiles & myNavFile & vbCrLf
Next

End Sub


Home Property Example

This example searches for a navigation node with the label "Sale", and then updates it.

Private Sub ChangeNavLabel()
Dim myFiles As WebFiles
Dim myFile As WebFile

Set myFiles = ActiveWeb.RootFolder.Files

For Each myFile in myFiles
    If myFile.NavigationNode.Home.Label = "Sale" Then
        myFile.NavigationNode.Home.Label = "Sales Items"
    End If
Next
End Sub


Web Property Example

This example returns the title of a FrontPage-based web.

Private Sub GetWebTitle()
Dim myWeb As Web
Dim myWebName As String

Set myWeb = ActiveWeb

myWebName = myWeb.RootFolder.Web.Title

End Sub