Class AutoCaption (Word VBA)
The class AutoCaption represents a single caption that can be automatically added when items such as tables, pictures, or OLE objects are inserted into a document. The AutoCaption object is a member of the AutoCaptions collection. The AutoCaptions collection contains all the captions listed in the AutoCaption dialog box. To use a AutoCaption class variable it first needs to be instantiated, for example
Dim acn as AutoCaption
Set acn = AutoCaptions(Index:=1)
For Each
Here is an example of processing the AutoCaption items in a collection.
Dim acn As AutoCaption
For Each acn In AutoCaptions
Next acn
AutoInsert
True if a caption is automatically added when the item is inserted into a document.
AutoCaptions("Microsoft Word Table").AutoInsert = True
Selection.Collapse Direction:=wdCollapseStart
ActiveDocument.Tables.Add Range:=Selection.Range, _
NumRows:=2, NumColumns:=2
CaptionLabel
Returns or sets the caption label ("Figure," "Table," or "Equation," for example) of the specified caption. Read/write Variant.
This property can be set to a string or a WdCaptionLabelID constant.
Dim acLoop As AutoCaption
For Each acLoop In AutoCaptions
If acLoop.AutoInsert = True Then MsgBox acLoop.Name _
& vbCr & "Label = " & acLoop.CaptionLabel.Name
Next acLoop
Index
Returns a Long that represents the position of an item in a collection.
Dim lngIndex As Long
lngIndex = AutoCaptions(1).Index
Name
Returns or sets the name of the specified object.
Dim strName As String
strName = AutoCaptions(1).Name