Word允许您创建样式来定义文档中的文本应如何显示。除了内置样式的完整列表之外,Word还允许您创建可能需要的任何自定义样式。您可以稍后为文档打印样式表,如_WordTips_的其他问题所述。

但是,如果您只想列出自定义样式,该怎么办? Word不包含允许您区分样式表打印输出中包含哪些样式的功能。如果要在文档中使用自定义样式的列表,则可以使用宏来创建一个。下面的宏逐步浏览所有样式,并列出同时满足两个条件(自定义和使用)的样式列表:

Sub PrintCustomStyles()

Dim docThis As Document     Dim styItem As Style     Dim sUserDef(499) As String     Dim iStyleCount As Integer     Dim J As Integer

' Ref the active document     Set docThis = ActiveDocument

iStyleCount = 0     For Each styItem In docThis.Styles         'see if being used         If styItem.InUse Then             'make sure not built in             If Not styItem.BuiltIn Then                 iStyleCount = iStyleCount + 1                 sUserDef(iStyleCount) = styItem.NameLocal             End If         End If     Next styItem

If iStyleCount > 0 Then         ' Create the output document         Documents.Add

Selection.TypeText "User-defined Styles In Use"

Selection.TypeParagraph         For J = 1 To iStyleCount             Selection.TypeText sUserDef(J)

Selection.TypeParagraph         Next J         Selection.TypeParagraph         Selection.TypeParagraph     Else         MsgBox "No custom styles in use."

End If End Sub

请记住,“自定义样式”和“自定义样式”之间是有区别的。 (如果更改样式的默认特征,则内置样式可以是自定义样式。)它完全忽略了Word认为内置的样式。

注意:

如果您想知道如何使用此页面(或_WordTips_网站上的任何其他页面)上描述的宏,我准备了一个包含有用信息的特殊页面。

_WordTips_是您进行经济有效的Microsoft Word培训的来源。

(Microsoft Word是世界上最流行的文字处理软件。)本技巧(1530)适用于Microsoft Word 97、2000、2002和2003。您可以找到Word(Word 2007)的功能区界面的本技巧版本。和更高版本)在这里: