![]() |
|
#2
|
||||
|
||||
|
Looping through all paragraphs in a long document and testing all possible combinations is liable to be quite slow. What I'd be inclined to use is a Find/Replace that looks for the primary Styles of interest, then check what precedes them, thus:
Code:
Sub Demo()
Application.ScreenUpdating = False
Dim ArrFnd, ArrPre, ArrRep, i As Long
ArrFnd = Array("List: Bullet", "List: Numbered")
ArrPre = Array("Body Text", "Body Text")
ArrRep = Array("Body Text: Pre-list", "Body Text: Pre-list")
For i = 0 To UBound(ArrFnd)
With ActiveDocument.Range
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = True
.Style = ArrFnd(i)
.Execute
End With
Do While .Find.Found
If .Information(wdWithInTable) = True Then
.End = .Tables(1).Range.End
Else
With .Paragraphs.First.Previous.Range.Paragraphs.First
If .Style = ArrPre(i) Then .Style = ArrRep(i)
End With
End If
If .End = ActiveDocument.Range.End Then Exit Do
.Collapse wdCollapseEnd
.Find.Execute
Loop
End With
Next
Application.ScreenUpdating = True
End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Help on using scenarios in Excel | tjthomps23 | Excel | 0 | 01-20-2017 10:09 AM |
| How can I generate Scenarios? | tommade | Excel Programming | 0 | 02-18-2016 04:56 PM |
| Lookup multiple values and compare different scenarios to get a specific result | mws | Excel | 5 | 05-24-2014 04:52 AM |
Creating a multiple choice test
|
McDoug | Office | 2 | 10-19-2012 10:02 AM |
How to make a multiple-choice test?
|
micahfaulkner75 | Mail Merge | 1 | 09-12-2012 06:08 PM |