Convert outline to a multilevel list
-
- 3StarLounger
- Posts: 254
- Joined: 09 May 2020, 14:00
Convert outline to a multilevel list
I have a Word document downloaded from the Web. This document contains almost 70 different outlines, but none of them are connected. If I look at the styles, the entire document is in Normal, but if I right click on the outline, I can choose to adjust.
How can I get set the whole document so it use the same multilevel throughout, that way I can adjust indent and such all at once.
How can I get set the whole document so it use the same multilevel throughout, that way I can adjust indent and such all at once.
-
- Administrator
- Posts: 78457
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Convert outline to a multilevel list
I 'd assign heading styles to the outline paragraphs.
Best wishes,
Hans
Hans
-
- 3StarLounger
- Posts: 254
- Joined: 09 May 2020, 14:00
Re: Convert outline to a multilevel list
Not entirely following. I know how to create the styles, but wouldn't you have to apply the styles to each level of the outline?
-
- Administrator
- Posts: 78457
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Convert outline to a multilevel list
Yes, Heading 1 for level 1, Heading 2 for level 2 etc.
Best wishes,
Hans
Hans
-
- 3StarLounger
- Posts: 254
- Joined: 09 May 2020, 14:00
Re: Convert outline to a multilevel list
Thanks, I'll give it a go
-
- 4StarLounger
- Posts: 508
- Joined: 17 Dec 2010, 03:14
Re: Convert outline to a multilevel list
What numbering format is used for the various levels (e.g. 1, 1.1, 1.1.1, etc)?
Paul Edstein
[Fmr MS MVP - Word]
[Fmr MS MVP - Word]
-
- 3StarLounger
- Posts: 254
- Joined: 09 May 2020, 14:00
Re: Convert outline to a multilevel list
Hi Paul,
It starts with roman numeral I
It's I, A, 1, a, i
It starts with roman numeral I
It's I, A, 1, a, i
-
- 5StarLounger
- Posts: 615
- Joined: 10 Jan 2016, 15:56
- Location: Madison, Wisconsin
Re: Convert outline to a multilevel list
Paul may come up with a macro for you. In the meantime, see Shauna Kelly's How to Create Outlines or Numbered Headings
Attorney Charles Kenyon
Templates in Microsoft Word
Modifying the QAT
The Importance of Styles in Microsoft Word
Templates in Microsoft Word
Modifying the QAT
The Importance of Styles in Microsoft Word
-
- 4StarLounger
- Posts: 508
- Joined: 17 Dec 2010, 03:14
Re: Convert outline to a multilevel list
Try the following two macros.
The first macro applies your numbering scheme to the first 5 heading levels. You'll see a line with '.TextPosition = CentimetersToPoints(0.5 + i * 0.5)'. This indents each heading level by 0.5cm. You could use InchesToPoints instead to use those, and you could change the 0.5 to something else.
The second macro goes through your document looking for paragraphs whose first word conforms to one of those levels and applies that level to the paragraph. It is assumed that each level's numbering restarts once content at the previous level is encountered.
The first macro applies your numbering scheme to the first 5 heading levels. You'll see a line with '.TextPosition = CentimetersToPoints(0.5 + i * 0.5)'. This indents each heading level by 0.5cm. You could use InchesToPoints instead to use those, and you could change the 0.5 to something else.
The second macro goes through your document looking for paragraphs whose first word conforms to one of those levels and applies that level to the paragraph. It is assumed that each level's numbering restarts once content at the previous level is encountered.
Code: Select all
Sub ApplyMultiLevelHeadingNumbers()
Dim LT As ListTemplate, i As Long
Set LT = ActiveDocument.ListTemplates.Add(OutlineNumbered:=True)
For i = 1 To 5
With LT.ListLevels(i)
.NumberFormat = Choose(i, "%1", "%2", "%3", "%4", "%5")
.TrailingCharacter = wdTrailingTab
.NumberStyle = Choose(i, wdListNumberStyleUppercaseRoman, wdListNumberStyleUppercaseLetter, _
wdListNumberStyleArabic, wdListNumberStyleLowercaseLetter, wdListNumberStyleLowercaseRoman)
.NumberPosition = 0
.Alignment = wdListLevelAlignLeft
.TextPosition = CentimetersToPoints(0.5 + i * 0.5)
.ResetOnHigher = True
.StartAt = 1
.LinkedStyle = "Heading " & i
End With
Next
End Sub
Code: Select all
Sub ApplyHeadingStyles()
Dim Para As Paragraph, Rng As Range, i As Long, StrTxt As String, bLvl As Boolean
Dim objUndo As UndoRecord: Set objUndo = Application.UndoRecord
With ActiveDocument.Range
For Each Para In .Paragraphs
With Para
StrTxt = Trim(.Range.Words.First.Text): bLvl = False
objUndo.StartCustomRecord ("Fmt")
For i = 1 To 5
.Style = "Heading " & i
If .Range.ListFormat.ListString = StrTxt Then
.Range.Words.First.Text = vbNullString
bLvl = True: Exit For
End If
Next
objUndo.EndCustomRecord
If bLvl = False Then ActiveDocument.Undo
End With
Next
End With
End Sub
Last edited by macropod on 12 Jul 2022, 08:41, edited 1 time in total.
Paul Edstein
[Fmr MS MVP - Word]
[Fmr MS MVP - Word]
-
- 3StarLounger
- Posts: 254
- Joined: 09 May 2020, 14:00
Re: Convert outline to a multilevel list
Hi Paul,
Evidently I am not understanding how this works, plus, the second macro debugs on
Sub or Function not defined
The first macro ran, but not all that sure what it did.
Here is a pared-down version of the doc. As you can see, everything is in Normal style, but the outlines are in order. I just would like to control the outline with the styles so I can adjust the spacing, fonts, indents, etc.
Evidently I am not understanding how this works, plus, the second macro debugs on
Code: Select all
If bLvl = False Then Undo
The first macro ran, but not all that sure what it did.
Here is a pared-down version of the doc. As you can see, everything is in Normal style, but the outlines are in order. I just would like to control the outline with the styles so I can adjust the spacing, fonts, indents, etc.
You do not have the required permissions to view the files attached to this post.
-
- 4StarLounger
- Posts: 508
- Joined: 17 Dec 2010, 03:14
Re: Convert outline to a multilevel list
Your list-level numbering is not as described. Rather than being 'I, A, 1, a, i', it is 'I., A., 1., a., i.'. Plus your Heading Styles use a range of formats that I suspect you don't really want. All of that can be addressed by:
The code I previously posted also assumed your document was manually numbered. As it is auto-numbered, use:
Code: Select all
Sub ApplyMultiLevelHeadingNumbers()
Dim LT As ListTemplate, i As Long
Set LT = ActiveDocument.ListTemplates.Add(OutlineNumbered:=True)
For i = 1 To 5
With LT.ListLevels(i)
.NumberFormat = Choose(i, "%1.", "%2.", "%3.", "%4.", "%5.")
.TrailingCharacter = wdTrailingTab
.NumberStyle = Choose(i, wdListNumberStyleUppercaseRoman, wdListNumberStyleUppercaseLetter, _
wdListNumberStyleArabic, wdListNumberStyleLowercaseLetter, wdListNumberStyleLowercaseRoman)
.NumberPosition = 0
.Alignment = wdListLevelAlignLeft
.TextPosition = CentimetersToPoints(1.25 + i * 1.25)
.ResetOnHigher = True
.StartAt = 1
.LinkedStyle = "Heading " & i
End With
With ActiveDocument.Styles("Heading " & i)
.ParagraphFormat.LeftIndent = CentimetersToPoints(i * 1.25 - 1.25)
.ParagraphFormat.FirstLineIndent = CentimetersToPoints(-1.25)
.Font.Name = "Gill Sans MT"
.Font.Italic = False
.Font.Bold = False
.Font.ColorIndex = wdAuto
.Font.Size = 17 - i
End With
Next
End Sub
Code: Select all
Sub ApplyHeadingStyles()
Dim Para As Paragraph, Rng As Range
With ActiveDocument.Range
For Each Para In .Paragraphs
With Para.Range
If .ListFormat.ListString <> "" Then
.Style = "Heading " & .ListFormat.ListLevelNumber
End If
End With
Next
End With
End Sub
Last edited by macropod on 04 May 2021, 21:33, edited 1 time in total.
Paul Edstein
[Fmr MS MVP - Word]
[Fmr MS MVP - Word]
-
- 3StarLounger
- Posts: 254
- Joined: 09 May 2020, 14:00
Re: Convert outline to a multilevel list
Thank you Paul. This will work nicely.
-
- 3StarLounger
- Posts: 254
- Joined: 09 May 2020, 14:00
Re: Convert outline to a multilevel list
Hi Paul,
Hope I can ask a follow-up question.
How can the next section restart with I.?
Right now on the attached doc, the next section continuous from the previous, so it's, starting with III.
Hope I can ask a follow-up question.
How can the next section restart with I.?
Right now on the attached doc, the next section continuous from the previous, so it's, starting with III.
-
- 4StarLounger
- Posts: 508
- Joined: 17 Dec 2010, 03:14
Re: Convert outline to a multilevel list
Simply go to Home|Paragraph>Numbering>Set Number Value and choose '1'.
Paul Edstein
[Fmr MS MVP - Word]
[Fmr MS MVP - Word]
-
- 3StarLounger
- Posts: 254
- Joined: 09 May 2020, 14:00
Re: Convert outline to a multilevel list
Maybe I'm not quite understanding and missing the big picture, but wouldn't this still be a manual process?
I can do this fine by selecting Restart with I., but this gets a little wearisome after 70+ outlines.
I can do this fine by selecting Restart with I., but this gets a little wearisome after 70+ outlines.
-
- 5StarLounger
- Posts: 615
- Joined: 10 Jan 2016, 15:56
- Location: Madison, Wisconsin
Re: Convert outline to a multilevel list
Then move your list entries down one level and use a non-numbered level at the top to restart numbering.
Attorney Charles Kenyon
Templates in Microsoft Word
Modifying the QAT
The Importance of Styles in Microsoft Word
Templates in Microsoft Word
Modifying the QAT
The Importance of Styles in Microsoft Word
-
- 3StarLounger
- Posts: 254
- Joined: 09 May 2020, 14:00
Re: Convert outline to a multilevel list
Hi Charles, thanks for the follow-up. I think I have it all sorted now.
-
- 4StarLounger
- Posts: 508
- Joined: 17 Dec 2010, 03:14
Re: Convert outline to a multilevel list
I was working from the implications of your previous post, which seems to suggest some sections have more than one Heading 1 paragraph, viz:
If the Section you want to re-start at I is III rather than II, the implication is that the II is to be retained. In that case, it's impossible for Word to know when you want to re-start and when you don't
Paul Edstein
[Fmr MS MVP - Word]
[Fmr MS MVP - Word]
-
- 3StarLounger
- Posts: 254
- Joined: 09 May 2020, 14:00
Re: Convert outline to a multilevel list
Right now, every outline is separated by a page break. Can this be considered a section and then each section would restart with I.?
Also, each new outline starts with the words Detailed Notes.
Also, each new outline starts with the words Detailed Notes.