2017-05-24 81 views
0

我试图以编程方式将构建块插入到使用VBA的Microsoft Word中,并且当插入工作时,在打印预览中查看时以及打印时,不会显示构建块。VBA插入的构建块不打印

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 

如果我手动插入积木,它打印的很好。

我通过插入一个形状,然后将其添加到

AutoText > General > Normal.dotm > Insert content only 

创建积木如果我尝试一个新的文档重新创建这个问题,它不会发生,但我不能确定这两个文档之间的属性不同

+0

当您手动插入它时,你插入在完全相同的地方?当你从你的代码中插入它时,它会被插入到字体被隐藏的段落中? –

+0

形状被插入隐藏字体的表格单元格中。修好后,它现在打印。如果你想写一个答案,我会除了它。 – CDO

+0

谢谢,正式答复! –

回答

1

如果在打印预览中形状消失,可能是因为在形状锚定的段落的字体设置中设置了隐藏属性。

这也解释了为什么你不能在不同的文档中复制问题。