![]() |
|
|
|
#1
|
||||
|
||||
|
Hi ExpatChic,
Try the following. I had to make some changes to your code, as it wasn't working. Code:
Sub Demo()
Application.ScreenUpdating = False
Dim vFindText As String, vColor As String, x As Long
With ActiveDocument.Range.Find
.ClearFormatting
.Replacement.ClearFormatting
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchWildcards = True
'Insert Page breaks before the paragraphs preceding the 'Cat #' paragraphs
.Text = "[!^13]{1,}^13Cat I"
.Replacement.Text = "^m^&"
.Execute Replace:=wdReplaceAll
'Delete any duplicate page breaks
.Text = "[^m]{2,}"
.Replacement.Text = "^m"
.Execute Replace:=wdReplaceAll
'Highlight the 'Cat #' paragraphs
.Replacement.Text = "^&"
.Replacement.Highlight = True
For x = 1 To 3
Select Case x
Case Is = 1
vFindText = "Cat I^13"
vColor = wdRed
Case Is = 2
vFindText = "Cat II^13"
vColor = wdYellow
Case Is = 3
vFindText = "Cat III^13"
vColor = wdPink
End Select
Options.DefaultHighlightColorIndex = vColor
.Text = vFindText
.Execute Replace:=wdReplaceAll
Next x
Options.DefaultHighlightColorIndex = wdNoHighlight
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Delete a page after Section Break Next Page
|
Aston | Word | 9 | 04-27-2022 07:38 AM |
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 |