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 / January 2005

Tip: Looking for answers? Try searching our database.

Changing Styles

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Vince - 07 Jan 2005 04:35 GMT
This is crazy. I am trying to change the style "COOL" in the document to
another style called "NOTSOCOOL". I wrote this:

With ActiveDocument.Range.Find
       .Style = "COOL"
       .ClearFormatting
       .MatchWildcards = False

          With .Replacement
               .Style = "NOTSOCOOL"
           End With

   .Execute Replace:=wdReplaceAll
End With

Doesn't work! I am positive that nothing extra is set, the same code (when
.style is removed and .text is added) finds and replaces words with no
problems. The styles definitely exist and I did a manual Find and Replace
(Edit - Find) and it works fine.

What's wrong with the code?

Thank you for your time / response

Vince
Word Heretic - 07 Jan 2005 06:40 GMT
G'day "Vince" <sdsad@fsd.com>,

I'd structure it more like

>With ActiveDocument.Range.Find
>        .ClearFormatting
[quoted text clipped - 6 lines]
>    .Execute Replace:=wdReplaceAll
>End With

but also, does the NOTSOCOOL style EXIST? Styles.Add "NOTSOCOOL"
first, and do an on error resume next

Steve Hudson - Word Heretic

steve from wordheretic.com (Email replies require payment)
Without prejudice

Vince reckoned:

>This is crazy. I am trying to change the style "COOL" in the document to
>another style called "NOTSOCOOL". I wrote this:
[quoted text clipped - 21 lines]
>
>Vince
Vince - 07 Jan 2005 07:17 GMT
Steve,

And I spent two hours on that!!! Don't believe it!

Thanks a lot, needless to say, it works fine!

Vince

> G'day "Vince" <sdsad@fsd.com>,
>
[quoted text clipped - 46 lines]
> >
> >Vince
Word Heretic - 08 Jan 2005 02:01 GMT
G'day "Vince" <sdsad@fsd.com>,

Well, I'm glad my 30 seconds was worth it then :-)

Steve Hudson - Word Heretic

steve from wordheretic.com (Email replies require payment)
Without prejudice

Vince reckoned:

>Steve,
>
[quoted text clipped - 55 lines]
>> >
>> >Vince
 
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.