L
LEU
I have documents with the following formattingâ€
Heading 1 Paragraph
Normal Hard return
Normal Paragraph
Normal Hard return
Table
Heading 2 Paragraph
Normal Hard return
Normal Paragraph
Normal Hard return
and so on…..
What I want the formatting to look like this:
Heading 1 Paragraph
Hd1 Hard return
Hd1 Paragraph
Hd1 Hard return
Table
Heading 2 Paragraph
Hd2 Hard return
Hd2 Paragraph
Hd2 Hard return
and so on…..
Heading 1, Heading 2, Hd1 and Hd2 are styles. I have a total of 7 Headings
and Hds
I have the following macro that almost works. It looks for all the Heading
1s and reformats the paragraphs below it to Hd1 but it also changes Heading 1
to Hd1. How do I keep this form happing?
Dim rTmp As Range
Dim rTmp1 As Range
Set rTmp = ActiveDocument.Range
With rTmp.Find
.Style = "Heading 1"
While .Execute
Set rTmp1 = rTmp.Duplicate
rTmp1.Select ' for testing
Do
While Not (rTmp1.Paragraphs.Last.Next Is Nothing)
If rTmp1.Paragraphs.Last.Next.Style = "Normal" Then
rTmp1.End = rTmp1.Paragraphs.Last.Next.Range.End
rTmp1.Select ' for testing
Else
Exit Do
End If
If rTmp1.Paragraphs.Last.Next Is Nothing Then
Exit Do
End If
Wend
Loop
With Selection.ParagraphFormat
.Style = "Hd1"
End With
rTmp.Start = rTmp1.End
rTmp.End = ActiveDocument.Range.End
If rTmp1.Paragraphs.Last.Next Is Nothing Then
Exit Sub
End If
Wend
End With
Selection.HomeKe
Heading 1 Paragraph
Normal Hard return
Normal Paragraph
Normal Hard return
Table
Heading 2 Paragraph
Normal Hard return
Normal Paragraph
Normal Hard return
and so on…..
What I want the formatting to look like this:
Heading 1 Paragraph
Hd1 Hard return
Hd1 Paragraph
Hd1 Hard return
Table
Heading 2 Paragraph
Hd2 Hard return
Hd2 Paragraph
Hd2 Hard return
and so on…..
Heading 1, Heading 2, Hd1 and Hd2 are styles. I have a total of 7 Headings
and Hds
I have the following macro that almost works. It looks for all the Heading
1s and reformats the paragraphs below it to Hd1 but it also changes Heading 1
to Hd1. How do I keep this form happing?
Dim rTmp As Range
Dim rTmp1 As Range
Set rTmp = ActiveDocument.Range
With rTmp.Find
.Style = "Heading 1"
While .Execute
Set rTmp1 = rTmp.Duplicate
rTmp1.Select ' for testing
Do
While Not (rTmp1.Paragraphs.Last.Next Is Nothing)
If rTmp1.Paragraphs.Last.Next.Style = "Normal" Then
rTmp1.End = rTmp1.Paragraphs.Last.Next.Range.End
rTmp1.Select ' for testing
Else
Exit Do
End If
If rTmp1.Paragraphs.Last.Next Is Nothing Then
Exit Do
End If
Wend
Loop
With Selection.ParagraphFormat
.Style = "Hd1"
End With
rTmp.Start = rTmp1.End
rTmp.End = ActiveDocument.Range.End
If rTmp1.Paragraphs.Last.Next Is Nothing Then
Exit Sub
End If
Wend
End With
Selection.HomeKe