InsertStyleSeparator 方法 (Word)Selection.InsertStyleSeparator method (Word)

插入特殊隐藏段落标记,使 Microsoft Word 可以使用不同的段落样式合并段落格式,以便在目录中插入内置标题。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.

语法Syntax

expression.expression. InsertStyleSeparator

_表达式_是必需的。expression Required. 表示 Selection 对象的变量。A variable that represents a Selection object.

示例Example

本示例在格式设置为内置“标题 4”样式的每个段落后插入样式分隔符。This example inserts a style separator after every paragraph formatted with the built-in "Heading 4" style.

备注

[!注释] 段落统计位于 Do...Loop 之内,因为当 Word 插入一个样式分隔符之后,两段变成一段,所以当该程序运行时,文档的段落统计就发生改变。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

另请参阅See also

Selection 对象Selection Object

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.