我正在尝试BuildingBlockEntries
通过 Microsoft Word 2007 中的宏访问模板集合的成员。由于它是一个集合,我首先认为For Each
循环是最好的方法:
For Each bBlock In NormalTemplate.BuildingBlockEntries
MessageBox.Show (bBlock.Name)
Next bBlock
但是,此尝试通过错误:Object doesn't support property or method
. 所以我尝试了这里建议的这种方法:
Templates.LoadBuildingBlocks
Dim iBB As Integer
iBB = NormalTemplate.BuildingBlockEntries.Count()
Dim bb As Word.BuildingBlock
Dim i As Integer
Dim objCounter As Object
If iBB > 0 Then
For i = 1 To iBB
objCounter = i
bb = NormalTemplate.BuildingBlockEntries.Item(objCounter)
MessageBox.Show (bb.Name)
Next
End If
但是,这会导致标题中显示的错误:Object variable or With Block variable not set
.
我试过只使用一个整数变量作为索引,i
特别是,但现在可用。我怎样才能达到预期的效果?我的尝试有什么问题?
感谢您的帮助。