Paragraph Character Linking


LinkStyle Property

Sets or returns a Variant that represents a link between a paragraph and a character style.
When a character style and a paragraph style are linked, the two styles take on the same character formatting.


This example creates and formats a new character style, and then it links the character style to the built-in heading style "Heading 1" so that the "Heading 1" style takes on the character formatting of the newly added style.

Sub LinkHeadStyle() 
    Dim styChar1 As Style

    Set styChar1 = ActiveDocument.Styles.Add(Name:="Heading 1 Characters", _
                                             Type:=wdStyleTypewdStyleTypeCharacter)
    With styChar1
        .Font.Name = "Verdana"
        .Font.Bold = True
        .Font.Shadow = True
        With .Font.Borders(1)
            .LineStyle = wdLineStyle.wdLineStyleDot
            .LineWidth = wdLineWidth.wdLineWidth300pt
            .Color = wdColor.wdColorDarkRed
        End With
    End With
    ActiveDocument.Styles("Heading 1").LinkStyle = ActiveDocument.Styles("Heading 1 Characters")

    With ActiveDocument.Content
        .InsertParagraphAfter
        .InsertAfter "New Linked Style"
        .Select
    End With

    Selection.Collapse Direction:=wdCollapseDirection.wdCollapseEnd
    Selection.Style = ActiveDocument.Styles("Heading 1")
End Sub


© 2022 Better Solutions Limited. All Rights Reserved. © 2022 Better Solutions Limited TopPrevNext