Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-09-2018, 03:59 PM
jeffreybrown jeffreybrown is offline Split paragraph into two different styles Windows Vista Split paragraph into two different styles Office 2007
Expert
Split paragraph into two different styles
 
Join Date: Apr 2016
Posts: 673
jeffreybrown has a spectacular aura aboutjeffreybrown has a spectacular aura about
Default Split paragraph into two different styles

I know how to do this manually by using the Style Seperator, but when recorded, I just get...

Code:
Sub Macro3()
    Selection.TypeParagraph
    Selection.InsertStyleSeparator
End Sub
I can find the word Statement of Conditions, but how do I find between the end of the word "Conditions" and the beginning of the word "The" to create the split? Statement of Conditions will Heading 1 and the rest of the paragraph will just be Normal style.

Quote:
Statement of Conditions. The normal hours of operation vary depending on size and/or location: smaller libraries usually operate 20-40 hours per week and larger libraries operate 40- 60 hours per week. There are no general conditions (environmental, equipment, facility, performance standards, or wartime conditions) that have an impact on the manpower requirements.
I'm using a couple of macros to first apply Heading 1 to three different words and then applying Heading 2 to everything in-between Heading 1.



Example and macros attached with before and after.
Attached Files
File Type: docm Standard Data.docm (20.8 KB, 10 views)
Reply With Quote
  #2  
Old 09-09-2018, 07:42 PM
macropod's Avatar
macropod macropod is online now Split paragraph into two different styles Windows 7 64bit Split paragraph into two different styles Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

For example:
Code:
Sub Demo()
Application.ScreenUpdating = False
Dim Rng As Range
Set Rng = Selection.Range
With ActiveDocument.Range
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "Statement of Conditions"
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindStop
    .Format = False
    .MatchWildcards = True
    .Execute
  End With
  Do While .Find.Found
    .Paragraphs.First.Style = wdStyleNormal
    .InsertAfter vbCr
    .Style = wdStyleHeading1
    .Select
    Selection.InsertStyleSeparator
    .Collapse wdCollapseEnd
    .Find.Execute
  Loop
End With
Rng.Select
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 09-09-2018, 09:02 PM
jeffreybrown jeffreybrown is offline Split paragraph into two different styles Windows Vista Split paragraph into two different styles Office 2007
Expert
Split paragraph into two different styles
 
Join Date: Apr 2016
Posts: 673
jeffreybrown has a spectacular aura aboutjeffreybrown has a spectacular aura about
Default

Thank you Paul. This works great.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I order the paragraph styles list? Tunathedog Word 3 04-08-2016 05:37 AM
Split paragraph into two different styles Split pilcrow or paragraph symbol nfotx Word 2 12-05-2014 02:48 PM
Split a paragraph bnyamin Word VBA 13 10-05-2014 08:18 PM
Split paragraph into two different styles Changing Paragraph Styles mjawatney Word 6 04-20-2014 05:15 PM
Split paragraph into two different styles Multiple styles in same paragraph? Cobb78 Word 1 05-20-2012 03:04 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:28 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft