About Word

M

mickaxel

Hello,

I'm new in VBA on word. I'm going to describe my problem.
I have a word document in which each line contains one or sevral word
in a color (blue) a space and a word without any color.
What I need to do is to place beetween these blue words and the other
pipe (|). For example :

One line of my text :

accepter un pari take a bet

And I would like to change all the lines in my document by

accepter un pari | take a bet

Thanks in advanc
 
D

Doug Robbins - Word MVP - DELETE UPPERCASE CHARACT

Use Edit>Replace, click on the More button and check the Use Wildcards box,
then with the cursor in the find what box, click on the Format button and
select Font and then Font Colour and select Blue. Then enter the following
into the Find what box

([A-z]{1,})

and in the Replace with box, enter

\1 |

Then click on Replace All

For more information on wildcard seaches, see the article “Finding and
replacing characters using wildcards” at:

http://word.mvps.org/FAQs/General/UsingWildcards.htm


--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP
 
K

Klaus Linke

I have a word document in which each line contains one or
sevral words in a color (blue) a space and a word without any color.
What I need to do is to place beetween these blue words and the
other a pipe (|). [...]


Hi Mic,

It sounds as if it is enough to put a pipe symbol after any blue text.

You can do it manually with Find/Replace:
Search for "Format > Font > Color: blue", and replace with ^&|
(Leave the "Find what:" box empty; ^& puts in the found text)

The macro recorder should give you the code.

If you want to check whether any line contains more than one "|", there's a
trick:
Select the text, go into "Tables > Convert > Text to table", and choose the
pipe as the delimiter.
If Word suggests two columns, there's only one "|" in every paragraph.

In case it gets more complicated, wildcard find/replace can come in handy.

Greetings,
Klaus
 

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