如何查找项目符号列表和格式化项目符号 (VBA _ Word Documnet)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23014639/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to Find Bullet List and Format Bullets (VBA _ Word Documnet)
提问by Ravenous
I'm trying to find instances of a bullet list in a document then change the bullet type and bullet size.
我正在尝试在文档中查找项目符号列表的实例,然后更改项目符号类型和项目符号大小。
I was trying to change the following style code so that it would use a bullet type that is formatted to the size and type of bullet i want but I can't seem to figure out the correct object to call or the correct properties to assign.
我试图更改以下样式代码,以便它使用格式设置为我想要的项目符号大小和类型的项目符号类型,但我似乎无法确定要调用的正确对象或要分配的正确属性。
I have added a custom bullet type and size to the bullet list it is in position nine(9) of the list, if that helps.
如果有帮助,我已将自定义项目符号类型和大小添加到项目符号列表中,它位于列表的九 (9) 位置。
I was tried to change the "list Paragraph" to a bullet type but kept keeping an error.
我试图将“列表段落”更改为项目符号类型,但一直保持错误。
Sub BulletStyle ()
Dim oBull As Word.Paragraph
For Each oBull In ActiveDocument.Paragraphs
If oBull.Range.ListFormat.ListType = _
WdListType.wdListBullet Then
oBull.Style = "List Paragraph"
End If
Next
End Sub
采纳答案by Mike
Create a Custom Style that is set to the bullet you want to change it to and make sure format is set to "Numbering" in the style definition.
创建一个自定义样式,该样式设置为要更改为的项目符号,并确保样式定义中的格式设置为“编号”。
Then simply change the following line of code
然后只需更改以下代码行
oBull.Style = "List Paragraph"
To the name of your custom style:
到您的自定义样式的名称:
oBull.Style = "MyCustomStyle"
When you create your Custom Style make sure to set Format as Numbering.
创建自定义样式时,请确保将格式设置为编号。