Replacing Text

B

Bob Phillips

I have some code that is looping through all instances of a particular
character style and adds some extra bits to the text. So far so good, but
....

Whatever I do, the replacement text comes out as upper-case, which gives me
a problem. Here is the code. Anyone any idea know how I can get the case I
want?

Sub CharacterStyles(sStyle)
With ActiveDocument.Range.Find
.ClearFormatting
.Style = ActiveDocument.Styles(sStyle)
.Text = ""
.MatchCase = True
.Replacement.ClearFormatting
.Replacement.Text = "<span class='" & LCase(sStyle) & "'>^&</span>"
.Forward = True
.Execute Replace:=wdReplaceAll
End With
End Sub

TIA

Bob
 
C

Cindy M -WordMVP-

Hi Bob,
Whatever I do, the replacement text comes out as upper-case, which gives me
a problem. Here is the code. Anyone any idea know how I can get the case I
want?
Is "all caps" font formatting applied to the target range? Have you tried
setting MatchCase to false?
Sub CharacterStyles(sStyle)
With ActiveDocument.Range.Find
.ClearFormatting
.Style = ActiveDocument.Styles(sStyle)
.Text = ""
.MatchCase = True
.Replacement.ClearFormatting
.Replacement.Text = "<span class='" & LCase(sStyle) & "'>^&</span>"
.Forward = True
.Execute Replace:=wdReplaceAll
End With
End Sub

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 

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