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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top