J
JosephSmith
Hi need help with trying to loop a building block - it won't insert.
Building block is saved in Building Blocks.dotx for the moment as:
Custom Autotext
Category Receipts
Title Receipt
Error Highlighted:
Set objBB = objTemplate.BuildingBlockTypes(wdTypeCustomAutoText) _ *** Error Requested Member of Collection Does not Exist
.Categories("Receipts").BuildingBlocks("Receipt")
Sub TestMe1()
Dim intReceipt As Integer
Dim i As Integer
Dim objTemplate As Template
Dim objBB As BuildingBlock
intReceipt = InputBox("How many Receipts do you need?", "Number of Receipts")
Do While i < intReceipt
'Insert the Building Block Entry
' Set the template to store building block
Set objTemplate = ActiveDocument.AttachedTemplate
' Access the building block through the type and category
Set objBB = objTemplate.BuildingBlockTypes(wdTypeCustomAutoText) _ *** Error Requested Member of Collection Does not Exist
.Categories("Receipts").BuildingBlocks("Receipt")
' Insert building block in document replacing any selected text.
objBB.Insert Selection.Range
' ActiveDocument.AttachedTemplate.AutoTextEntries("Receipt").Insert _
' Where:=Selection.Range, RichText:=True
' 'Make sure the cursor is at the end of the Receipt
' Selection.EndKey Unit:=wdStory
'Increment the counter
i = i + 1
Loop
End Sub
Building block is saved in Building Blocks.dotx for the moment as:
Custom Autotext
Category Receipts
Title Receipt
Error Highlighted:
Set objBB = objTemplate.BuildingBlockTypes(wdTypeCustomAutoText) _ *** Error Requested Member of Collection Does not Exist
.Categories("Receipts").BuildingBlocks("Receipt")
Sub TestMe1()
Dim intReceipt As Integer
Dim i As Integer
Dim objTemplate As Template
Dim objBB As BuildingBlock
intReceipt = InputBox("How many Receipts do you need?", "Number of Receipts")
Do While i < intReceipt
'Insert the Building Block Entry
' Set the template to store building block
Set objTemplate = ActiveDocument.AttachedTemplate
' Access the building block through the type and category
Set objBB = objTemplate.BuildingBlockTypes(wdTypeCustomAutoText) _ *** Error Requested Member of Collection Does not Exist
.Categories("Receipts").BuildingBlocks("Receipt")
' Insert building block in document replacing any selected text.
objBB.Insert Selection.Range
' ActiveDocument.AttachedTemplate.AutoTextEntries("Receipt").Insert _
' Where:=Selection.Range, RichText:=True
' 'Make sure the cursor is at the end of the Receipt
' Selection.EndKey Unit:=wdStory
'Increment the counter
i = i + 1
Loop
End Sub