Style Property
Applies To
Find object, HeadingStyle object, LineFormat object, Paragraph object, ParagraphFormat object, Paragraphs collection object, Range object, Replacement object, Selection object.
Description
Returns or sets the style for the specified object. To set this property, specify either the local name of the style, an integer or a WdBuiltinStyle constant (see "Remarks"), or an object that represents the style. Read/write Variant.
Remarks
When you return the style for a range that includes more than one style, only the first character or paragraph style is returned.
The Style property can be one of the following WdBuiltinStyle constants:
| |
| |
- wdStyleBodyTextFirstIndent
| - wdStyleBodyTextFirstIndent2
|
| |
| |
| |
| |
- wdStyleDefaultParagraphFont
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
- wdStyleTableOfAuthorities
| |
| |
| |
See Also
AutoFormat method, Styles property.
Example
This example displays the style for each paragraph in the active document.
For Each para in ActiveDocument.Paragraphs
MsgBox para.Style
Next para
This example displays the style for each character in the selection. Each element of the Characters collection is a Range object.
For each c in Selection.Characters
MsgBox c.Style
Next c
This example sets alternating styles of Heading 3 and Normal for all the paragraphs in the active document.
For i = 1 To ActiveDocument.Paragraphs.Count
If i Mod 2 = 0 Then
ActiveDocument.Paragraphs(i).Style = wdStyleNormal
Else: ActiveDocument.Paragraphs(i).Style = wdStyleHeading3
End If
Next i
This example finds all instances of the Heading 1 style in the active document and replaces them with the Heading 2 style.
With ActiveDocument.Content.Find
.ClearFormatting
.Style = wdStyleHeading1
.Replacement.ClearFormatting
.Replacement.Style = wdStyleHeading2
.Execute FindText:="", ReplaceWith:="", _
Replace:=wdReplaceAll, Format:=True
End With