I'm trying to insert a condition in the code here below. The style should be replaced only if the number of italicized characters is less than 30. Can someone help? Thanks!
Code:
Sub Italic()
With ActiveDocument
If Not .Styles("myItalic") Is Nothing Then
For iType = 1 To 2
Set aRng = ActiveDocument.StoryRanges(iType)
With aRng.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = ""
.Replacement.Text = ""
.Font.Italic = True
If aRng.Characters.Range.Count < 30 Then _
.Replacement.Style = ActiveDocument.Styles("myItalic")
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.Execute Replace:=wdReplaceAll
End With
Next iType
End If
End With
End Sub