Log in

View Full Version : Convert levels to heading automaticaly?



Programmer_n
05-20-2017, 11:20 PM
The situation:

I got my heading style set and the numbering 1, 1.1.,1.1.1 linked to the relevant levels (Heading 1, Heading2, Heading 3, and so on).

Doc looks like

1. Heading 1
1.1 Heading 2
1.1.1 Heading 3

When i click either the number (1.) or the heading it shows that, it is set to the respective heading. But, it doesn't get reflected in the text.

For example. I set heading 1 to 12 pt, all caps, bold, but it shows as normal.

I need to manually click on each and every level and set it to the style.
Is it possible to sense numbering and set corresponding heading?

My efforts, so far, has been in line with this link.

https://answers.microsoft.com/en-us/msoffice/forum/msoffice_word-mso_winother/convert-manual-numbering-10-11-111-112-to/275b6a32-e17d-4f3b-994b-06b808f408e4

Please help.

macropod
05-21-2017, 05:51 AM
I posted two macros in that thread, one to convert manually numbered text to a corresponding heading level; the other to apply multi-level list numbering to the headings. Neither has any effect on the Heading Style or font attributes for the numbering. To match the numbering font formats to the Heading Styles, you could use:

Sub ApplyMultiLevelHeadingNumbers()
Dim LT As ListTemplate, i As Long, Fnt As Font
Set LT = ActiveDocument.ListTemplates.Add(OutlineNumbered:=True)
For i = 1 To 9
With LT.ListLevels(i)
.NumberFormat = Choose(i, "%1", "%1.%2", "%1.%2.%3", "%1.%2.%3.%4", "%1.%2.%3.%4.%5", "%1.%2.%3.%4.%5.%6", "%1.%2.%3.%4.%5.%6.%7", "%1.%2.%3.%4.%5.%6.%7.%8", "%1.%2.%3.%4.%5.%6.%7.%8.%9")
.TrailingCharacter = wdTrailingTab
.NumberStyle = wdListNumberStyleArabic
.NumberPosition = CentimetersToPoints(0)
.Alignment = wdListLevelAlignLeft
.TextPosition = CentimetersToPoints(0.5 + i * 0.5)
.ResetOnHigher = True
.StartAt = 1
.LinkedStyle = "Heading " & i
Set Fnt = ActiveDocument.Styles("Heading " & i).Font
With .Font
.Name = Fnt.Name
.Size = Fnt.Size
.Bold = Fnt.Bold
.Italic = Fnt.Italic
End With
End With
Next
End Sub

Programmer_n
05-22-2017, 06:11 PM
Thanks for the effort. I figured out, my need is

Right click on the heading style and select "all instances of heading" and apply style.

I tried to record a macro for that, but unable to apply heading.

macropod
05-22-2017, 06:18 PM
Given there are only 9 heading levels, most of which you probably don't use, it wouldn't be worthwhile developing a macro for that.