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 / Long Documents / September 2005

Tip: Looking for answers? Try searching our database.

Format between Styles

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
<*(((><{ - 18 Sep 2005 04:15 GMT
I have a long document (several thousand pages) that has heads using
Heading Style 1 through Heading Style 5.  I would like to apply a
style to the body text between Heading 2 and Heading 3.  

Is there a way to set up a Find/Replace to do that for me?  

<*((((><{
Fishy@Ocean.Net
Herb Tyson [MVP] - 18 Sep 2005 20:17 GMT
Not unless there's some unique text in every Heading 2 and Heading 3
heading. Find/Replace lets you find a style, but only one per find. Hence,
you can locate Heading 2 or Heading 3, but not both (and certainly not with
something else sandwiched in-between). Wildcard searches are really good
with text patterns, but limited when it comes to formatting patterns.

It wouldn't be terribly hard to set up a macro to do it, however.

Signature

Herb Tyson MS MVP
Please respond in the newsgroups so everyone can follow along.
http://www.herbtyson.com

>I have a long document (several thousand pages) that has heads using
> Heading Style 1 through Heading Style 5.  I would like to apply a
[quoted text clipped - 4 lines]
> <*((((><{
> Fishy@Ocean.Net
Greg Maxey - 18 Sep 2005 22:03 GMT
While it was probably harder for me than Herb can imagine, I think I finally
figured it out.

Try:
Sub ApplyNewStyleBetweenTweUniqueStyles()
Dim oRng As Range
Dim oTempRng As Range
Set oRng = ActiveDocument.Content
With oRng.Find
 'Look for the Heading 2 text on execute
 .Style = "Heading 2"
 .Wrap = wdFindStop
 While .Execute
   'Collapse oRng to end of found Heading 2 text
   oRng.Collapse wdCollapseEnd
   'Set a temporary range that starts at end of Heading 2 text
   Set oTempRng = oRng.Duplicate
   'Look for Heading 3 text on execute
   .Style = "Heading 3"
   .Execute
      'Collapse oRng to start of Heading 3 text
      oRng.Collapse wdCollapseStart
      'Define temporary range that ends where Heading 3 text starts
      oTempRng.End = oRng.End
      'Apply style
      oTempRng.Style = "MyStyle"
      'Set execute to look for Heading 2 text
      .Style = "Heading 2"
   Wend
End With
End Sub

Where "MyStyle" is the name of the style you want to apply.

Signature

Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

> Not unless there's some unique text in every Heading 2 and Heading 3
> heading. Find/Replace lets you find a style, but only one per find.
[quoted text clipped - 12 lines]
>> <*((((><{
>> Fishy@Ocean.Net
Herb Tyson [MVP] - 18 Sep 2005 22:48 GMT
Wow! That's surprisingly similar to the one that took me 30 seconds to
record.

JUST KIDDING!!!

;-)

Signature

Herb Tyson MS MVP
Please respond in the newsgroups so everyone can follow along.
http://www.herbtyson.com

> While it was probably harder for me than Herb can imagine, I think I
> finally figured it out.
[quoted text clipped - 46 lines]
>>> <*((((><{
>>> Fishy@Ocean.Net
Greg Maxey - 18 Sep 2005 22:53 GMT
Yoouuuu!!!
That "Just Kidding" line was the only thing that kept a vein from bursting
;-)

Signature

Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

> Wow! That's surprisingly similar to the one that took me 30 seconds to
> record.
[quoted text clipped - 59 lines]
>>>> <*((((><{
>>>> Fishy@Ocean.Net
<*(((><{ - 20 Sep 2005 05:30 GMT
I love you guys!  Thank you.  I'll give the macro a try and let you
know how it works.  :-)

Happy Fishy
<*((((><{
Fishy@Ocean.Net

Rate this thread:






 
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.