Excel で VBA コードを使用して、Word 文書で番号付きリストを作成しようとしています。
Dim wrdApp As Word.Application
Dim wrdDoc As Word.Document
Set wrdApp = CreateObject("Word.Application")
wrdApp.Visible = True
Set wrdDoc = wrdApp.Documents.Add
With wrdDoc
For i = 0 To 5
.Content.InsertAfter ("Paragraph " & i)
.Content.InsertParagraphAfter
Next
.Paragraphs(1).Range.ListFormat.ApplyListTemplateWithLevel ListTemplate:= _
ListGalleries(wdNumberGallery).ListTemplates(1), ContinuePreviousList:= _
False, ApplyTo:=wdListApplyToWholeList, DefaultListBehavior:= _
wdWord10ListBehavior
End With
Set wrdApp = Nothing
Set wrdDoc = Nothing
これを実行すると、エラーが発生します。
オブジェクト「ListFormat」のメソッド「ApplyListTemplateWithLevel」が失敗しました
Microsoft Word 12.0 Object Library
Excel VBA 参照リストで確認しました。