View Single Post
 
Old 06-05-2013, 12:55 PM
jasserin jasserin is offline Windows XP Office 2007
Novice
 
Join Date: Jun 2013
Posts: 1
jasserin is on a distinguished road
Angry INSERT building blocks from Quickpart in word

Hello,

New in vba. I search to insert very simply a building block from quickpart inside my word document but I can't. I have find the classical VBA code :

Code:
Sub InsertExistingBuildingBlock()
 
Dim objTemplate As Template
Dim objBB As BuildingBlock
 
' 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(wdTypeCustomHeaders) _
.Categories("Book Titles").BuildingBlocks("Title")
 
' Insert the building block into the document replacing any selected 
text.
objBB.Insert Selection.Range
 
End Sub
But it is not working.

Another link advices to load preliminary the templates with :

Templates.LoadBuildingBlocks

I do it and I have try this following code :

Code:
Sub InsertExistingBuildingBlock()
 
Dim objTemplate As Template
Dim objBB As BuildingBlock
 
' 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(Bibliographies) _
.Categories("Prédifini").BuildingBlocks("Travaux cités")
 
' Insert the building block into the document replacing any selected 
text.
objBB.Insert Selection.Range
 
End Sub
But it is not working

I have try this folowing code to indicate the way of the file building blocks.dotx

Code:
Sub TestBuildingBlocks()
 
Templates.LoadBuildingBlocks ' chargement du template building blocks
 
Templates("C:\Utilisateur\ utilisateur\AppData\Roaming\Microsoft\Document Building Blocks\1036\Building Blocks.dotx"). _
BuildingBlockTypes("bibliography").Categories("Prédéfini").BuildingBlocks("Travaux cités").Insert Where:=Selection.Range
 
End Sub
It doesn't work !

Could you please help me to insert a building block from quickparts. I enclosed 2 images from the templates and the quickparts content.

I need your help,

Thank you very much,

sincerely

jasserin
Attached Images
File Type: jpg quickpart.jpg (82.5 KB, 19 views)
File Type: jpg vba building blocks.jpg (64.6 KB, 18 views)

Last edited by macropod; 09-29-2013 at 08:49 PM. Reason: Added code tags
Reply With Quote