webbots 属性

       

返回 IHTMLElementCollection 集合,该集合代表当前文档中所有 Web 组件的集合。

expression.webbots

expression  必选。返回 DispFPHTMLDocument 对象的表达式。

说明

此集合先按名称索引,再按标识符索引。如果发现相同的名称,则返回具有该名称的项目的集合。相同名称的集合随后必须按位置序号进行引用。

示例

下列示例创建对当前文档的 Web 组件集合的引用,并显示当前网页中 Web 组件的数目。

Sub ReturnWebBots()
'Returns the collection of all webbots in the document

    Dim objApp As FrontPage.Application
    Dim objBots As IHTMLElementCollection
    Dim objBot As IHTMLElement
    Dim intCount As Integer

    intCount = 0
    Set objApp = FrontPage.Application
    Set objBots = objApp.ActiveDocument.webbots
    'For each webbot in the document
    For Each objBot In objBots
       'Keep count of number of webbots
       intCount = intCount + 1
    Next objBot

    'Display number of webbots in collection
    If intCount = 0 Then
        MsgBox "There are no webbots in the current document."
    Else
        MsgBox "There are " & intCount & " webbots in the current document."
    End If

End Sub