Word VBA教程:ApplyPictureBullet方法

用图片项目符号设置段落或段落区域的格式。

expression.ApplyPictureBullet(FileName)

expression   必需。该表达式返回“应用于”列表中的一个对象。

FileName  String 类型,必需。图片文件的路径和文件名。

VBA示例

本示例创建一个具有列表的新文档,并将图片符号列表格式应用于除首段和末段外的所有段落。


Sub ApplyPictureBulletsToParagraphs()
    Dim docNew As Document
    Dim rngRange As Range
    Dim lstTemplate As ListTemplate
    Dim intPara As Integer
    Dim intCount As Integer
    'Set the initial value of object variables
    Set docNew = Documents.Add
    'Add paragraphs to the new document, including eight list items
    With Selection
        .TypeText Text:="This is an introductory paragraph."
        .TypeParagraph
    End With
    Do Until intPara = 8
        With Selection
            .TypeText Text:="This is a list item."
            .TypeParagraph
        End With
        intPara = intPara + 1
    Loop
    Selection.TypeText Text:="This is a concluding paragraph."
    'Count the total number of paragraphs in the document
    intCount = docNew.Paragraphs.Count
    'Set the range to include all paragraphs in the
    'document except the first and the last
    Set rngRange = docNew.Range( _
        Start:=ActiveDocument.Paragraphs(2).Range.Start, _
        End:=ActiveDocument.Paragraphs(intCount - 1).Range.End)
    'Format the list template as a bullet
    Set lstTemplate = ListGalleries(Index:=wdBulletGallery) _
        .ListTemplates(7)
    'Format list with a picture bullet
    lstTemplate.ListLevels(1).ApplyPictureBullet _
                FileName:="c:\pictures\bluebullet.gif"
    'Apply the list format settings to the range
    rngRange.ListFormat.ApplyListTemplate _
        ListTemplate:=lstTemplate
End Sub

Word VBA教程

Word VBA参考教程:目录1 Word VBA参考教程:目录2
Word VBA参考教程:目录3 Word VBA参考教程:目录4
Word VBA参考教程:目录5 Word VBA参考教程:目录6
Word VBA参考教程:目录7 Word VBA参考教程:目录8
Word VBA参考教程:目录9 Word VBA参考教程:目录10
版权所有 © 中山市飞娥软件工作室 证书:粤ICP备09170368号