A
andreas
Dear Experts:
I tried to write a macro that is supposed to look for custom numbered
heading styles, level 1 ("custom_heading_1") in a document and insert a
section break (next page) automatically before these headings.
Running the below macro I get an error saying that "parameter value was
out of acceptable range" and the macro line "Selection.InsertBreak
Type:=wdSectionBreakNext" gets highlighted.
I guess I have to define a range or something.
Help is appreciated. Thank you very much in advance.
Sub InsertSection()
Selection.HomeKey unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Style = ActiveDocument.Styles("custom_heading_1")
With Selection.Find
.Text = ""
.Forward = True
.Wrap = wdFindStop
.Execute
End With
While Selection.Find.Found
Selection.InsertBreak Type:=wdSectionBreakNext
Selection.Find.Execute
Wend
End Sub
I tried to write a macro that is supposed to look for custom numbered
heading styles, level 1 ("custom_heading_1") in a document and insert a
section break (next page) automatically before these headings.
Running the below macro I get an error saying that "parameter value was
out of acceptable range" and the macro line "Selection.InsertBreak
Type:=wdSectionBreakNext" gets highlighted.
I guess I have to define a range or something.
Help is appreciated. Thank you very much in advance.
Sub InsertSection()
Selection.HomeKey unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Style = ActiveDocument.Styles("custom_heading_1")
With Selection.Find
.Text = ""
.Forward = True
.Wrap = wdFindStop
.Execute
End With
While Selection.Find.Found
Selection.InsertBreak Type:=wdSectionBreakNext
Selection.Find.Execute
Wend
End Sub