Caption Property Example

This statement returns the caption of the active page.

myCaption = ActivePageWindow.Caption

This example demonstrates accessing both the active WebWindow and PageWindow objects using the With and For statements.

Private Sub GetPageWindowCaption()
Dim myWebWindow As WebWindow
Dim myPageWindows As PageWindows
Dim myPageWindowCaptions As String
Dim myWebWindowCaption As String

Set myWebWindow = Application.ActiveWebWindow
Set myPageWindows = myWebWindow.PageWindows

With myWebWindow
    myWebWindowCaption = .Caption
End With

For Each myPageWindow in myPageWindows
    myPageWindowCaptions = myPageWindowCaption & myPageWindow.Caption
Next
End Sub