View Single Post
 
Old 11-29-2022, 06:16 AM
stky stky is offline Windows 10 Office 2013
Advanced Beginner
 
Join Date: Apr 2021
Posts: 30
stky is on a distinguished road
Default Create & Apply Character Styles for Export to InDesign

If the document exists the style leave else need to create the character style.

after that can create more style like this.

Code:
Sub CStyle()

    Dim objDoc As Document
    Dim cbolditalic As Style
    Set objDoc = ActiveDocument

    Set cbolditalic = ActiveDocument.Styles.Add("*italic", Type:=WdStyleType.wdStyleTypeCharacter)
    With cbolditalic.Font
        .Name = "Times New Roman"
        .Bold = False
        .italic = True
        .Subscript = False
        .Superscript = False

    End With

    Dim rngStory As Range
    For Each rngStory In ActiveDocument.StoryRanges

        Application.ScreenUpdating = False
        With ActiveDocument.Range
            With rngStory.Find

                Options.DefaultHighlightColorIndex = wdYellow
                .ClearFormatting
                .Replacement.ClearFormatting
                .Text = ""
                .Replacement.Text = ""
                .MatchWildcards = True
                .Format = True
                .Forward = True
                .Wrap = wdFindContinue

                .Font.Bold = False
                .Font.italic = True
                .Font.Subscript = False
                .Font.Superscript = False
                .Replacement.Style = "*italic"
                .Replacement.Highlight = True
                .Execute Replace:=wdReplaceAll


            End With
        End With
    Next rngStory
    Application.ScreenUpdating = True
End Sub
Reply With Quote