2017-05-24 84 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

如果在打印預覽中形狀消失,可能是因爲在形狀錨定的段落的字體設置中設置了隱藏屬性。

這也解釋了爲什麼你不能在不同的文檔中複製問題。