![]() |
#4
|
||||
|
||||
![]()
OK, try the following instead
Code:
Sub Macro1() Dim oRng As Range Dim oPara As Paragraph If Len(Selection.Range) = 0 Then MsgBox "Nothing selected", vbCritical Exit Sub End If For Each oPara In Selection.Paragraphs If oPara.Range.Style Like "Heading #" Then Set oRng = oPara.Range oRng.Collapse 1 oRng.MoveEndUntil Chr(9) oRng.End = oRng.End + 1 oRng.Collapse 0 oRng.Text = vbCr Set oRng = oRng.Next.Paragraphs(1).Range oRng.Style = "Normal" End If Next oPara lbl_Exit: Set oPara = Nothing Set oRng = Nothing Exit Sub End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Inserting heading number AFTER heading text | Aunt Pauline | Word | 1 | 08-29-2019 03:24 PM |
![]() |
FuriousD | Word VBA | 1 | 05-12-2019 04:06 AM |
![]() |
Dr Wu | Word | 4 | 07-15-2018 03:52 AM |
![]() |
eNGiNe | Word | 4 | 06-17-2018 11:05 PM |
Control the size of space between heading number and heading text | Dr Wu | Word | 1 | 07-17-2013 12:24 PM |