Find&Replace formatted (bold + underline) text

J

John Svendsen

Hi All:

I'm wondering if you've seen this before:

In doing translations I find&replace many, many strings of text in Word
2003 - however increasingly, there are bold and underlined words in these
strings of text and these words aren't in the same order of words as the
source when translated.BTY, I align translation pairs in Excel 2003 to
translate these sentences, thend convert them into a text file and
Find&Replace in Word.

What I was thinking was to insert RTF-like keywords (\b, \un, etc) between
these formatted words in the source and when translating the string insert
these keywords in the correct new order. I think it'd be somewaht easy to
insert these keywords with Word's Find format (ex: find "BOLD" replace with
"\b ^& \b0")

But I'm at a loss of how to create a macro tha'll find this formatted string
in word (using the unformatted source string with the keywords as find) and
relace this string using the target string (and re-format this target string
obeying the keywords).

Has anyone seen any sort of macro that'll do this Find&Replace or have any
insights into how this might be done?

Thank you very much for your help and attention.

Regards, JS
 
D

Doug Robbins - Word MVP on news.microsoft.com

The following macro will apply bold formatting to the words inside \b \b0,
deleting the \b and \b0 in the process:

Selection.HomeKey wdStory
Selection.Find.ClearFormatting
Dim frange As Range
With Selection.Find
Do While .Execute(FindText:="[\\]b*[\\]b0", Forward:=True, _
MatchWildcards:=True, Wrap:=wdFindStop, MatchCase:=False) = True
Set frange = Selection.Range
frange.Text = Mid(frange.Text, 3, Len(frange.Text) - 5)
frange.Font.Bold = True
Loop
End With


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
J

John Svendsen

Hi Doug,
Thanks for your reply - hadn't thought of it this way. Will try this out.
Rgds, JS

Doug Robbins - Word MVP on news.microsoft.com said:
The following macro will apply bold formatting to the words inside \b
\b0, deleting the \b and \b0 in the process:

Selection.HomeKey wdStory
Selection.Find.ClearFormatting
Dim frange As Range
With Selection.Find
Do While .Execute(FindText:="[\\]b*[\\]b0", Forward:=True, _
MatchWildcards:=True, Wrap:=wdFindStop, MatchCase:=False) = True
Set frange = Selection.Range
frange.Text = Mid(frange.Text, 3, Len(frange.Text) - 5)
frange.Font.Bold = True
Loop
End With


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com

John Svendsen said:
Hi All:

I'm wondering if you've seen this before:

In doing translations I find&replace many, many strings of text in Word
2003 - however increasingly, there are bold and underlined words in these
strings of text and these words aren't in the same order of words as the
source when translated.BTY, I align translation pairs in Excel 2003 to
translate these sentences, thend convert them into a text file and
Find&Replace in Word.

What I was thinking was to insert RTF-like keywords (\b, \un, etc)
between these formatted words in the source and when translating the
string insert these keywords in the correct new order. I think it'd be
somewaht easy to insert these keywords with Word's Find format (ex: find
"BOLD" replace with "\b ^& \b0")

But I'm at a loss of how to create a macro tha'll find this formatted
string in word (using the unformatted source string with the keywords as
find) and relace this string using the target string (and re-format this
target string obeying the keywords).

Has anyone seen any sort of macro that'll do this Find&Replace or have
any insights into how this might be done?

Thank you very much for your help and attention.

Regards, JS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top