frames 属性

       

返回 IHTMLFramesCollection2 集合,该集合代表由给定文档或与给定窗口相关联的文档定义的所有窗口的集合。

expression.frames

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

说明

虽然在此集合的 item 属性中可以使用名称,但是该方法不会返回集合。相反,它始终返回具有指定名称的第一个窗体。若要确保所有窗口都可访问,应该始终确保文档中没有两个同名的框架。

示例

下列示例显示当前文档中所有框架的名称和位置。如果文档不包含框架,则向用户显示一条消息。

Sub ReturnFrames()
'Returns the collection of all window objects defined in the
'current document.

    Dim objFrm As IHTMLFramesCollection2
    Dim i as Integer

    Set objFrm = ActiveDocument.frames
    'If there are frames in the document
    If Not objFrm.Length = 0 Then
        'For every frame in the collection
        For i = 0 To objFrm.Length - 1
            'Display name and location
            MsgBox "The window " & objFrm(i).Name & _
                   "has the path: " & objFrm(i).location
        Next i
    Else
        'Otherwise display message
        MsgBox "There are no frames in the current document."
    End If
End Sub