使用圖片式項目符號,格式化某個段落或某個範圍的段落。
語法
expression。 ApplyPictureBullet( _FileName_ )
需要 expression。 代表 'ListLevel' 物件的變數。
參數
| 名稱 | 必要/選用 | 資料類型 | 描述 |
|---|---|---|---|
| FileName | 必要 | String | 圖片檔的路徑和檔名。 |
範例
這則範例會建立一份含有清單的新文件,然後將圖片式符號項目格式套用至所有段落,不過第一和最後一個段落除外。
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
另請參閱
支援和意見反應
有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應。