View Single Post
 
Old 12-03-2023, 03:08 AM
vivka vivka is offline Windows 7 64bit Office 2016
Expert
 
Join Date: Jul 2023
Posts: 302
vivka is on a distinguished road
Default

Hi, RobiNew! Try this:
Code:
Sub Italicize_If()

Dim aRng As range
  For iType = 1 To 2
    Set aRng = ActiveDocument.StoryRanges(iType)
    With aRng.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .text = ""
        .Replacement.text = ""
        .Font.Italic = True
        .Forward = True
        .Wrap = wdFindStop
        .Format = True
        .MatchCase = False
        Do
           If .Execute And aRng.Characters.count < 30 Then
               aRng.Select
               selection.Style = "myItalic"
           End If
           aRng.Collapse wdCollapseEnd
        Loop While .found
    End With
  Next iType
lbl_exit:
Set aRng = Nothing 
Exit Sub
End Sub
Reply With Quote