![]() |
|
#1
|
|||
|
|||
|
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
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Find & Replace to insert thousands separators
|
jeffreybrown | Word | 3 | 10-19-2019 04:37 PM |
Find and replace condition
|
norgro | Word VBA | 2 | 07-31-2015 06:38 AM |
Find and Replace - How to insert brackets around all numbers in a doc
|
Natedogg | Word | 2 | 05-21-2015 07:16 AM |
Insert text at the end of a sentence Find/Replace
|
AlmostFriday | Word | 6 | 06-17-2012 05:21 AM |
| Find & Replace Insert Issue | mipacker | Word | 0 | 02-18-2009 08:59 AM |