K
Keith G Hicks
Word vba 2003.
Okay, this has to be easy but after an hour I'm not getting this to work. I
need to italicize text that's between ^ markers.
For example:
Now ^is^ the time for all ^good^ men to come to the aid of ^their^
country....
The ^ are ALWAYS in pairs. I need all the text that's between ^ to be in
italics. I'm seearching for the first instance of the ^ and I can find it
but then I need to set the range to be the text between (it can include the
^ too, that's okay) and then italicize it. Then I need to remove all the ^
in the entire doc.
Like I said, just not figuring out how to mark the end as the 2nd ^ in my
loop. Here's the mess I'm workign with:
With Selection
.HomeKey wdStory
With .Find
.ClearFormatting
.Replacement.ClearFormatting
While .Execute(findtext:="^", MatchWildcards:=False)
Set oRng = Selection.Range
oRng.End = .Execute(findtext:="^", MatchWildcards:=False)
'oRng.End = oRng.Next(wdCharacter, 1).End
oRng.Font.Italic = True
If .Execute(findtext:="^", MatchWildcards:=False) Then
oRng.End = oRng.GoTo.Find
End If
'sNewTextFound = oRng
'If sNewTextFound <> sPrevTextFound Then
' oRng.InsertBefore vbCrLf
' sPrevTextFound = sNewTextFound
'End If
Wend
End With
End With
Keith
Okay, this has to be easy but after an hour I'm not getting this to work. I
need to italicize text that's between ^ markers.
For example:
Now ^is^ the time for all ^good^ men to come to the aid of ^their^
country....
The ^ are ALWAYS in pairs. I need all the text that's between ^ to be in
italics. I'm seearching for the first instance of the ^ and I can find it
but then I need to set the range to be the text between (it can include the
^ too, that's okay) and then italicize it. Then I need to remove all the ^
in the entire doc.
Like I said, just not figuring out how to mark the end as the 2nd ^ in my
loop. Here's the mess I'm workign with:
With Selection
.HomeKey wdStory
With .Find
.ClearFormatting
.Replacement.ClearFormatting
While .Execute(findtext:="^", MatchWildcards:=False)
Set oRng = Selection.Range
oRng.End = .Execute(findtext:="^", MatchWildcards:=False)
'oRng.End = oRng.Next(wdCharacter, 1).End
oRng.Font.Italic = True
If .Execute(findtext:="^", MatchWildcards:=False) Then
oRng.End = oRng.GoTo.Find
End If
'sNewTextFound = oRng
'If sNewTextFound <> sPrevTextFound Then
' oRng.InsertBefore vbCrLf
' sPrevTextFound = sNewTextFound
'End If
Wend
End With
End With
Keith