Style Property Example

This example returns the style associated with the current author for unsent replies, forwards, or new e-mail messages, and displays the name of the font associated with this style.

Set MyEmailStyle = _
    ActiveDocument.Email.CurrentEmailAuthor.Style
Msgbox MyEmailStyle.Font.Name

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