AutoCaptions Collection Object

Microsoft Word Visual Basic

Multiple objectsAutoCaptions
AutoCaption

A collection of AutoCaption objects that represent the captions that can be automatically added when items such as tables, pictures, or OLE objects are inserted into a document.

Using the AutoCaptions Collection

Use the AutoCaptions property to return the AutoCaptions collection. The following example displays the names of the selected items in the AutoCaption dialog box.

For Each autoCap In AutoCaptions
    If autoCap.AutoInsert = True Then
        MsgBox autoCap.Name & " is configured for auto insert"
    End If
Next autoCap
		

The AutoCaptions collection contains all the captions listed in the AutoCaption dialog box (Insert menu). AutoCaption objects cannot be programmatically added to or deleted from the AutoCaptions collection.

Use AutoCaptions(index), where index is the caption name or index number, to return a single AutoCaption object. The caption names correspond to the items listed in the AutoCaption dialog box (Insert menu). You must exactly match the spelling (but not necessarily the capitalization) of the name, as it's shown in the AutoCaption dialog box. The following example displays the caption text "Microsoft Word Table."

MsgBox AutoCaptions("Microsoft Word Table").CaptionLabel.Name
		

The index number represents the position of the AutoCaption object in the list of captions in the AutoCaption dialog box. The following example displays the name of the first item selected in the AutoCaption dialog box.

MsgBox AutoCaptions(1).Name