Word VBA: 如何判断给定的n个段落是否设了项目编号等
Word VBA:
如何判断给定的n个段落是否设了项目编号? 如果设置了, 如何得到并显示编号的类型?
我知道可以在操作中记录宏,但是,我的问题是反的:
下面我兴趣个例子:假如我想知道第二至第四段这三个段落即paragraphs(2),paragraphs(3)和paragraphs(4)有没有设置项目编号,如果设了是什么类型的,如何用VBA实现?
为了方便帮助我的朋友我把我录制的宏放在下面:
我的文档有五个段落。我选中了中间的三段,给它们设置了格式为1.2.3.的项目编号。这个过程我记录的宏代码如下:
Sub Macro13()
'
' Macro13 Macro
' 宏在 2012-3-8 由 微软用户 录制
'
With ListGalleries(wdNumberGallery).ListTemplates(1).ListLevels(1)
.NumberFormat = "%1."
.TrailingCharacter = wdTrailingTab
.NumberStyle = wdListNumberStyleArabic
.NumberPosition = CentimetersToPoints(0)
.Alignment = wdListLevelAlignLeft
.TextPosition = CentimetersToPoints(0.74)
.TabPosition = CentimetersToPoints(0.74)
.ResetOnHigher = 0
.StartAt = 1
With .Font
.Bold = wdUndefined
.Italic = wdUndefined
.StrikeThrough = wdUndefined
.Subscript = wdUndefined
.Superscript = wdUndefined
.Shadow = wdUndefined
.Outline = wdUndefined
.Emboss = wdUndefined
.Engrave = wdUndefined
.AllCaps = wdUndefined
.Hidden = wdUndefined
.Underline = wdUndefined
.Color = wdUndefined
.Size = wdUndefined
.Animation = wdUndefined
.DoubleStrikeThrough = wdUndefined
.Name = ""
End With
.LinkedStyle = ""
End With
ListGalleries(wdNumberGallery).ListTemplates(1).Name = ""
Selection.Range.ListFormat.ApplyListTemplate ListTemplate:=ListGalleries( _
wdNumberGallery).ListTemplates(1), ContinuePreviousList:=False, ApplyTo:= _
wdListApplyToWholeList, DefaultListBehavior:=wdWord9ListBehavior
End Sub
[解决办法]
对word vba不熟。
用你的代码研究了下,感觉这个没有直接的属性可以取到。