Replace with a formatted nonbreaking space

A

andreas

Hello:

I got a long document with lots of abbreviatons which should be
formatted by inserting a nonbreaking space that is formatted with font
size 4. One example:

The abbreviation is: "z.B."
Now "z.B." should be replaced by "z.+(nonbreaking space formatted with
font size 4)+B.

I tried a two step VBA replace in which I first replace "z.B" with
"z.####B." and then in a second step I replace "####" with a
nonbreaking space (^s) that is formatted with font size 4.

The result is that a non-formatted nonbreaking space is inserted, not a
formatted one. Can this be achieved somehow ?.

Help is appreciated. Thanks in advance.

Regards,

Andreas
 
D

Doug Robbins - Word MVP

Use a macro containing the following code:

Dim srange As Range
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:="z.B.", MatchWildcards:=False, _
MatchCase:=False, Wrap:=wdFindStop, Forward:=True) = True
Set srange = Selection.Range
srange = "z." & Chr(160) & "B."
srange.Start = srange.Start + 2
srange.End = srange.Start + 1
srange.Font.Size = 4
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
 
K

Klaus Linke

You could also insert a "six-per-em"-space U+2006 (type 2006, Alt+C in the
German version, or Alt+8198 in the Find dialog).

Word will likely switch to a large Unicode font for that character though,
which is a bit messy.
But so is changing the font size...

Regards,
Klaus
 
A

andreas

Doug:

Great, very good job. It is working fine. Thank you very much.

Regards,

Andreas
 

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