Export (0) Print
Expand All
Expand Minimize
This topic has not yet been rated - Rate this topic

Selection.InsertStyleSeparator Method (Word)

Published: July 16, 2012

Inserts a special hidden paragraph mark that allows Microsoft Word to join paragraphs formatted using different paragraph styles, so lead-in headings can be inserted into a table of contents.

expression .InsertStyleSeparator

expression Required. A variable that represents a Selection object.

This example inserts a style separator after every paragraph formatted with the built-in "Heading 4" style.

Note Note

The paragraph count is inside the Do...Loop because when Word inserts the style separator, the two paragraphs become one paragraph, so the paragraph count for the document changes as the procedure runs.

Sub InlineHeading() 
 Dim intCount As Integer 
 Dim intParaCount As Integer 
 
 intCount = 1 
 
 With ActiveDocument 
 Do 
 'Look for all paragraphs formatted with "Heading 4" style 
 If .Paragraphs(Index:=intCount).Style = "Heading 4" Then 
 .Paragraphs(Index:=intCount).Range.Select 
 
 'Insert a style separator if paragraph 
 'is formatted with a "Heading 4" style 
 Selection.InsertStyleSeparator 
 End If 
 intCount = intCount + 1 
 intParaCount = .Paragraphs.Count 
 Loop Until intCount = intParaCount 
 
 End With 
End Sub
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.