View Single Post
  #2   Report Post  
Posted to microsoft.public.word.newusers
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default replace format (subscript)

You can do it in stages.
Replace O2 with
O &&2
(Note the space)
Replace &&2
with ^& format superscript
Replace space&&
with nothing

or by macro

Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "O2"
.Replacement.Text = "O &&2"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "&&2"
.Replacement.Text = "^&"
.Replacement.Font.Superscript = True
End With
Selection.Find.Execute replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = " &&"
.Replacement.Text = ""
End With
Selection.Find.Execute replace:=wdReplaceAll

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org


Lamb Chop wrote:
Is it possible to do the following:

I would like to change "O2" to

Osubscript 2/subscript

I can only change the whole word "O2" to

subscript O2 /subscript

If I just replace "2", I will run into trouble because the whole
document has a lot of numbers.

I use office 2k

Thanks