Formatting in Word

D

David

Wondered if you could point me in the right direction to do some search and
replace formatting in Word.

Have done this in the past from the tutorials you have online but cannot
figure it out again. I would very much welcome some pointers.

I want to do a search for all characters between ± ² and change the text
between these delimiters to be bold and all upper case as below

Before: ±Jean-Martin Folz - Chairman of the Managing Board of PSA
Peugeot Citroën ²

After: ±JEAN-MARTIN FOLZ - CHAIRMAN OF THE MANAGING BOARD OF PSA PEUGEOT
CITROËN ²

The final search would be to remove ±² which is a more straight forward
search and replace.

Any help would be most appreciated.

Many thanks,



David
 
D

Doug Robbins - Word MVP

Use the following code in a macro:

Dim frange As Range
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(Findtext:="±*²", Forward:=True, _
MatchWildcards:=True, Wrap:=wdFindStop) = True
Set frange = Selection.Range
Selection.Collapse wdCollapseEnd
With frange
.Start = .Start + 1
.End = .End - 1
.Font.AllCaps = True
.Font.Bold = True
End With
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
 

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