From: Keith G Hicks on
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


From: macropod on
Hi Keith

Try using a wildcard Find/Replace with:
Find = '(^94[!^94]{1,}^94)'
Replace = '^&'
(making the replacement font bold and omitting the tick marks in both cases)

No macro required (though you could use one, somply recording the above).

--
Cheers
macropod
[Microsoft MVP - Word]


"Keith G Hicks" <krh(a)comcast.net> wrote in message news:Om4wpfOgKHA.2184(a)TK2MSFTNGP04.phx.gbl...
> 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
>
>
From: Greg Maxey on
Sub FindAndItalicBoundText()
Dim oRng As Range
Set oRng = ActiveDocument.Content
With oRng.Find
.ClearFormatting
.Text = "^^<*>^^"
.Forward = True
.Wrap = wdFindStop
.MatchWildcards = True
Do While .Execute
With oRng
.Characters.First.Delete
.Characters.Last.Delete
.Font.Italic = True
.Collapse wdCollapseEnd
End With
Loop
End With
End Sub

"Keith G Hicks" <krh(a)comcast.net> wrote in message
news:Om4wpfOgKHA.2184(a)TK2MSFTNGP04.phx.gbl...
> 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
>


From: macropod on
To delete the '^' characters at the same time, try using a wildcard Find/Replace with:
Find = '^94([!^94]{1,})^94'
Replace = '\1'
(making the replacement font bold and omitting the tick marks in both cases)


--
Cheers
macropod
[Microsoft MVP - Word]


"macropod" <macropod(a)invalid.invalid> wrote in message news:u58VH4OgKHA.3552(a)TK2MSFTNGP06.phx.gbl...
> Hi Keith
>
> Try using a wildcard Find/Replace with:
> Find = '(^94[!^94]{1,}^94)'
> Replace = '^&'
> (making the replacement font bold and omitting the tick marks in both cases)
>
> No macro required (though you could use one, somply recording the above).
>
> --
> Cheers
> macropod
> [Microsoft MVP - Word]
>
>
> "Keith G Hicks" <krh(a)comcast.net> wrote in message news:Om4wpfOgKHA.2184(a)TK2MSFTNGP04.phx.gbl...
>> 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
>>
>>