Hi Everyone,
I have a table in Access containing custom MS Word Building Block categories and names which are stored in Word Templates. I am trying to build an Access form where the user can select a building block name and programatically paste that building block into the active word document in the selected area.
The macro I am using works within Word, but not from Access (I have added the MS Word 16.0 Object Library in the Access VBA Editor). I also want to change this code to dynamically fill the names for the Categories and the Building Blocks from the selection in the Access Form.
Can anyone help?
Private Sub PasteBBlockInWordDoc ()
Dim objTemplate As Template
Dim objBB As BuildingBlock
Set objTemplate = ActiveDocument.AttachedTemplate
Set objBB = objTemplate.BuildingBlockTypes(wdTypeCustomAutoText) _
.Categories("SubOutcome").BuildingBlocks("*A1C1OptionA")
Selection.MoveUp Unit:=wdLine, Count:=1
objBB.Insert Selection.Range
End Sub
I have a table in Access containing custom MS Word Building Block categories and names which are stored in Word Templates. I am trying to build an Access form where the user can select a building block name and programatically paste that building block into the active word document in the selected area.
The macro I am using works within Word, but not from Access (I have added the MS Word 16.0 Object Library in the Access VBA Editor). I also want to change this code to dynamically fill the names for the Categories and the Building Blocks from the selection in the Access Form.
Can anyone help?
Private Sub PasteBBlockInWordDoc ()
Dim objTemplate As Template
Dim objBB As BuildingBlock
Set objTemplate = ActiveDocument.AttachedTemplate
Set objBB = objTemplate.BuildingBlockTypes(wdTypeCustomAutoText) _
.Categories("SubOutcome").BuildingBlocks("*A1C1OptionA")
Selection.MoveUp Unit:=wdLine, Count:=1
objBB.Insert Selection.Range
End Sub