Caption Property

Microsoft Word Visual Basic

Caption Property

       

TableOfFigures object: Returns or sets the label that identifies the items to be included in a table of figures. Corresponds to the \c switch for a TOC field. Read/write String.

Window or Application object: Returns or sets the caption text for the specified document or application window. Read/write String.

Remarks

To change the caption of the application window to the default text, set this property to an empty string ("").

Example

This example displays the caption of each window in the Windows collection.

Count = 1
For Each win In Windows
    MsgBox Prompt:=win.Caption, Title:="Window" & Str(Count) & _
    " Caption"
    Count = Count + 1
Next win

This example resets the caption of the application window.

Application.Caption = ""

This example sets the caption of the active window to the active document name.

ActiveDocument.ActiveWindow.Caption = ActiveDocument.FullName

This example changes the caption of the Word application window to include the user name.

Application.Caption = UserName & "'s copy of Word"

This example inserts a Table caption and then changes the caption of the first table of figures to "Table."

Selection.Collapse Direction:=wdCollapseStart
Selection.Range.InsertCaption "Table"
If ActiveDocument.TablesOfFigures.Count >= 1 Then
    ActiveDocument.TablesOfFigures(1).Caption = "Table"
End If