Class CaptionLabel (Word VBA)

The class CaptionLabel represents a single caption label. The CaptionLabel object is a member of the CaptionLabels collection. The items in the CaptionLabels collection are listed in the Label box in the Caption dialog box.

The main procedures of class CaptionLabel are Delete and CaptionLabels.Add

Set

To use a CaptionLabel class variable it first needs to be instantiated, for example

Dim cll as CaptionLabel
Set cll = CaptionLabels(Index:=1)

The following procedures can be used to set variables of type CaptionLabel: CaptionLabels.Add, CaptionLabels.Item and Application.CaptionLabels

For Each

Here is an example of processing the CaptionLabel items in a collection.

Dim cll As CaptionLabel
For Each cll In CaptionLabels
	
Next cll

Methods

These are the main methods of the CaptionLabel class

Delete - Deletes the specified caption label.

CaptionLabels(1).Delete

CaptionLabels.Add - Returns a CaptionLabel object that represents a custom caption label.

Dim strName As String: strName =  
Dim cll As CaptionLabel
Set cll = CaptionLabels.Add(Name:=strName)

Properties

BuiltIn true if the specified caption label is one of the built-in caption labels in Word.

Dim booBuiltIn As Boolean
booBuiltIn = CaptionLabels(1).BuiltIn

ChapterStyleLevel returns or sets the heading style that marks a new chapter when chapter numbers are included with the specified caption label.

CaptionLabels(1).ChapterStyleLevel =

ID returns a WdCaptionLabelID constant that represents the type for the specified caption label if the BuiltIn property of the CaptionLabel object is True.

Dim wclID As WdCaptionLabelID
wclID = CaptionLabels(1).ID

IncludeChapterNumber true if a chapter number is included with page numbers or a caption label.

CaptionLabels(1).IncludeChapterNumber = True

Name returns the name of the specified object.

Dim strName As String
strName = CaptionLabels(1).Name

NumberStyle returns or sets the number style for the CaptionLabel object.

CaptionLabels(1).NumberStyle = wdCaptionNumberStyleArabic

Parent returns an object that represents the parent object of the specified CaptionLabel object.

Dim objParent As Object
Set objParent = CaptionLabels(1).Parent

Position returns or sets the position of caption label text.

CaptionLabels(1).Position = wdCaptionPositionAbove

Separator returns or sets the character between the chapter number and the sequence number.

CaptionLabels(1).Separator = wdSeparatorColon

CaptionLabels.Count returns a Long that represents the number of caption labels in the collection.

Dim lngCount As Long
lngCount = CaptionLabels.Count

CaptionLabels.Parent returns an object that represents the parent object of the specified CaptionLabels object.

Dim objParent As Object
Set objParent = CaptionLabels.Parent