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 / April 2006

Tip: Looking for answers? Try searching our database.

search and replace style - 1st line correct style, but wrong font

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
FrankFromWisconsin - 21 Apr 2006 20:21 GMT
I have a macro that searches and replace one style for another.  This worked
fine until we upgraded to Word 2003.  Now, the first line gets the style
applied, but the font doesn't change.  The find must be working, but why
doesn't the font change?
Jezebel - 21 Apr 2006 23:50 GMT
Bug in your code is the most likely answer.

>I have a macro that searches and replace one style for another.  This
>worked
> fine until we upgraded to Word 2003.  Now, the first line gets the style
> applied, but the font doesn't change.  The find must be working, but why
> doesn't the font change?
Cooz - 24 Apr 2006 12:36 GMT
Hi Frank,

Record the macro again in 2003, or use this one:

Sub ReplaceStyle()
   With Selection.Find
       With .Replacement
           .ClearFormatting
           .Replacement.Style = ActiveDocument.Styles("ReplaceByStyle2")
           .Text = ""
       End With
       .ClearFormatting
       .Style = ActiveDocument.Styles("ReplaceStyle1")
       .Text = ""
       .Forward = True
       .Wrap = wdFindContinue
       .Format = True
       .Execute Replace:=wdReplaceAll
   End With
End Sub

Good luck,
Cooz
--
PS: If this is a satisfying answer to your question and you're logged in via
the Microsoft site, please click Yes to "Did this post answer the question?".
Thanks.

> I have a macro that searches and replace one style for another.  This worked
> fine until we upgraded to Word 2003.  Now, the first line gets the style
> applied, but the font doesn't change.  The find must be working, but why
> doesn't the font change?
 
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.