Code:
Sub Converttoheadingstyle()
Dim oPara As Paragraph
Dim oRng As Range
Dim oParRng As Range
Dim lngCount As Long
If Selection.Type = wdSelectionNormal Then: Set oRng = Selection.Range: Else: Set oRng = ActiveDocument.Range
For Each oPara In oRng.Paragraphs
lngCount = 0
Set oParRng = oPara.Range.Duplicate
If IsNumeric(oParRng.Characters(1)) Then
oParRng.Collapse wdCollapseStart
Do
oParRng.Move wdCharacter, 1
If oParRng.Characters.Last = "." Then lngCount = lngCount + 1
If Not IsNumeric(oParRng.Characters.Last) And oParRng.Characters.Last <> "." Then Exit Do
Loop
oPara.Style = ActiveDocument.Styles("Heading " & lngCount): oParRng.Text = ""
End If
Next oPara
lbl_Exit:
Exit Sub
End Sub