Caption 属性

       

返回指定对象的标题栏文本。只读,String 类型。

expression.Caption

expression  必选。返回“应用于”列表中的对象之一的表达式。

说明

Caption 属性根据指定对象的不同而返回不同的值。例如,PageWindowEx 对象的 Caption 属性返回打开网页的文件 URL,而 WebWindowEx 对象的 Caption 属性返回 Microsoft FrontPage 应用程序窗口的标题栏文本。

示例

本语句返回活动网页的标题。

myCaption = ActivePageWindow.Caption

本示例示范使用 WithFor 语句分别访问活动的 WebWindowExPageWindowEx 对象。

Private Sub GetPageWindowCaption()
    Dim myWebWindow As WebWindowEx
    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 = myPageWindowCaptions & myPageWindow.Caption
    Next
End Sub