返回 IHTMLElementCollection 集合对象,该对象代表当前文档中所有表单的集合。
expression.forms
expression 必选。返回 DispFPFPHTMLDocument 对象的表达式。
此集合先按名称索引,再按标识符索引。如果发现相同的名称,则返回具有该名称的项目的集合。相同名称的集合随后必须按位置序号进行引用。
下列示例返回当前文档中所有表单的集合。该子例程在集合中搜索名为 Project Name 的表单。如果找到该表单,则向用户显示其名称和索引值。
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