Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-08-2012, 04:06 AM
expatchic expatchic is offline Add Page Break to Document Windows 7 64bit Add Page Break to Document Office 2007
Novice
Add Page Break to Document
 
Join Date: Aug 2012
Posts: 3
expatchic is on a distinguished road
Default

Here you go:

Code:
Dim vFindText, vReplText As String
Dim vColor As String
Dim x As Integer
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
For x = 1 To 3
  Select Case x
    Case Is = 1
      vFindText = "Cat I"
      vColor = wdRed
    Case Is = 2
      vFindText = "Cat II"
      vColor = wdYellow
    Case Is = 3
      vFindText = "Cat III"
      vColor = wdPink
  End Select
  vReplText = vFindText
  With Selection.Find
    .Forward = True
    .Wrap = wdFindContinue
    .MatchWholeWord = True
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    .Format = True
    .MatchCase = False
    .Text = vFindText
    .Replacement.Text = vReplText
    .Replacement.Highlight = True
    .Execute Replace:=wdReplaceAll
    .Font.Color = vColor
  End With
Next x
Now the text is something like this:



blah blah blah blah
blah blah blah blah
one or more blank lines
Heading
Cat I (or II or III)
blah
blah
blah

This scenario repeats throughout a 600+ page document. I would like to insert a page break before each Heading...I.e. go back 2 lines. But, I would also like to check for the existence of a page break before adding another one.

I tried various forms of Do...Loop, but I got myself into an endless loop. :-)

Thank you for your help.

Last edited by macropod; 08-08-2012 at 04:45 AM. Reason: Added code tags & formatting
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Add Page Break to Document Delete a page after Section Break Next Page Aston Word 9 04-27-2022 07:38 AM
Add Page Break to Document Page break formatting changes Tom0822 Excel 1 03-19-2012 08:50 PM
Force a page break Emaleth9999 Mail Merge 1 02-09-2012 02:36 AM
paragaph hard break, soft break and ...strange break czomberzdaniela Word 2 12-03-2010 06:58 PM
Page Break Manolo Word 0 04-29-2009 11:04 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:18 PM.


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