![]() |
#12
|
||||
|
||||
![]()
This variation on Vivka's code avoids the selection object and hence it runs a lot faster.
Code:
Sub Italicize_If2() Dim aRng As Range, iType As Integer 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 While .Execute If aRng.Characters.Count < 30 Then aRng.Style = "myItalic" aRng.Collapse wdCollapseEnd Loop End With Next iType lbl_exit: Set aRng = Nothing Exit Sub End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
jeffreybrown | Word | 3 | 10-19-2019 04:37 PM |
![]() |
norgro | Word VBA | 2 | 07-31-2015 06:38 AM |
![]() |
Natedogg | Word | 2 | 05-21-2015 07:16 AM |
![]() |
AlmostFriday | Word | 6 | 06-17-2012 05:21 AM |
Find & Replace Insert Issue | mipacker | Word | 0 | 02-18-2009 08:59 AM |