frames Property

       

Returns an IHTMLFramesCollection2 collection that represents the collection of all windows defined by the given document or defined by the document associated with a given window.

expression.frames

expression   Required. An expression that returns a DispFPHTMLDocument object.

Remarks

Although you can use names with the item property on this collection, the method never returns a collection. Instead, it always returns the first window with the specified name. To ensure that all windows are accessible, you should always make sure that no two frames in a document have the same name.

Example

The following example displays the name and location of all frames in the current document. If the document contains no frames, a message is displayed to the user.

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