Conditional outlinepromote / outlinedemote

C

carim.fam

Hi,

After combining 5 documents together, I am now stuck trying, in
wdMasterView mode, using VBA to loop through over 300 headings in order
to promote or demote them, depending on the number of periods contained
in the first word of the paragraph's title ...

Thanks a lot for your assistance
Cheers
Carim
 
C

carim.fam

For the sake of documentation, and thanks to Cindy Meister from
Switzerland :

Do
Selection.HomeKey Unit:=wdLine
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
If InStr(Selection, ".") = 0 Then
Selection.Paragraphs.OutlinePromote
Else
StrWord = Left(Selection, InStr(Selection, " ") - 1)
NPer = UBound(Split(StrWord, ".")) - LBound(Split(StrWord,
"."))
Select Case NPer
Case 2: Selection.Paragraphs.OutlineDemote
Case 3: Selection.Paragraphs.OutlineDemote
Selection.Paragraphs.OutlineDemote
End Select
End If
Selection.HomeKey Unit:=wdLine
Loop While Selection.MoveDown(wdLine, 1) > 0

HTH
Carim
 
Top