Reputation: 352
I am trying to programmatically insert a building block into Microsoft Word using VBA, and while the insertion works, when viewing in print preview, and when printing, the building block does not appear.
Sub draw_point()
Dim objTemplate As Template
Dim objBB As BuildingBlock
Selection.MoveDown Unit:=wdLine, Count:=1
' Set the template to store the building block
Set objTemplate = ActiveDocument.AttachedTemplate
' Access the building block through the type and category
Set objBB = objTemplate.BuildingBlockTypes(wdTypeAutoText) _
.Categories("General").BuildingBlocks("point")
' Insert the building block into the document replacing any selected text.
objBB.Insert Selection.Range
End Sub
If I manually insert the building block it prints fine.
I am creating the building block by inserting a shape, then adding it to
AutoText > General > Normal.dotm > Insert content only
If I try to re-create this issue on a new document, it does not happen, but I'm unsure what properties differs between the two documents
Upvotes: 0
Views: 78
Reputation: 7850
If the shape disappears in print preview it is probably because in the Font settings for the paragraph where the shape is anchored the Hidden property is set.
This would also explain why you can't replicate the issue in a different document.
Upvotes: 1