forms Property

       

Returns an IHTMLElementCollection collection object that represents a collection of all forms in the current document.

expression.forms

expression   Required. An expression that returns a DispFPFPHTMLDocument object..

Remarks

This collection is indexed first by name, then by identifier. If duplicate names are found, a collection of those named items is returned. Collections of duplicate names must subsequently be referenced by ordinal position.

Example

The following example returns the collection of all forms in the current document. The subroutine searches through the collection for a form named Project Name Form. If the form is found, its name and index value are displayed to the user.

Sub ReturnForms()
'Returns the collection of forms in the document

    Dim objApp As FrontPage.Application
    Dim objDoc As DispFPHTMLDocument
    Dim objForms As IHTMLElementCollection
    Dim objForm As IHTMLFormElement
    Dim intCount As Integer

    intCount = 0
    Set objApp = FrontPage.Application
    Set objDoc = objApp.ActiveDocument
    'Create a reference to the forms collection
    Set objForms = objDoc.forms

    For Each objForm In objForms
        'If form is the project name form
        If objForm.Name = "Project Name Form" Then
            'Display name and position
            MsgBox "The form " & objForm.Name & " was found." & _
                   " It is positioned number " & intCount _
                   & " in the collection."
        End If
    'If not found, keep looking
    intCount = intCount + 1
    Next objForm

End Sub