Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / June 2005

Tip: Looking for answers? Try searching our database.

Replacing Text

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bob Phillips - 17 Jun 2005 22:47 GMT
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
Cindy M  -WordMVP- - 20 Jun 2005 10:06 GMT
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
[quoted text clipped - 8 lines]
>     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 :-)
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.