![]() |
#1
|
|||
|
|||
![]()
Test Doc to replace non numbered paras under numbered paras.docx
Hi, I'm hoping someone can help me with a macro I am trying to create that indents non-numbered paragraphs under Heading 1-7 but ignores if the next paragraph is a heading number, so: Heading 1 = Body1 Heading 2 = Body2 Heading 3 = Body3 Heading 4 = Body4 Heading 5 = Body5 Heading 6 = Body6 Heading 7 = Body7 So far the code works for Heading 1 but is removing the heading 2 numbering and making those as Body1. I haven't got as far as adding in the other heading/body levels until I can sort out this problem first. If anyone can advise what I'm missing in the code I would be really grateful. Thanks, Shelley Code:
Sub ChangeParasAfterHeading() Dim para As Paragraph, nextPara As Paragraph, oRng As Range If Selection.Type = wdSelectionIP Then MsgBox Prompt:="You have not selected any text!" Exit Sub End If Set oRng = Selection.Range With oRng For Each para In oRng.Paragraphs If para.Style = "Heading 1" Then Set nextPara = para.Next If Not nextPara Is Nothing Then nextPara.Style = "Body1" Else If para.Style = "Heading 2" Then Set nextPara = para.Next If Not nextPara Is Nothing Then nextPara.Style = "Body2" Else End If End If End If End If Next End With End Sub |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
WildfireS3 | Word | 2 | 05-18-2020 05:18 AM |
Indent on headings | nerion | Word | 5 | 04-11-2019 04:48 AM |
Difference between first line Indent and Left Indent | kingston123 | Word | 3 | 09-25-2018 02:47 PM |
Indent of first numbered heading different from subsequent headings | ultimateguy | Word | 1 | 08-12-2015 06:51 AM |
![]() |
bwofficer | Word | 2 | 12-12-2014 12:21 AM |