![]() |
|
#1
|
|||
|
|||
|
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
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
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
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 Last edited by macropod; 09-29-2013 at 08:49 PM. Reason: Added code tags |
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Building Blocks - WHY???
|
namedujour | Word | 5 | 05-03-2011 01:37 PM |
| Building Blocks in Outlook | namedujour | Outlook | 2 | 04-06-2011 06:29 AM |
Word - Attach Building Blocks
|
namedujour | Word | 0 | 04-04-2011 09:59 AM |
| Building blocks in 2007 | derohanes | Office | 6 | 03-05-2011 01:31 PM |
| Word 2007 Building Blocks - difficult to update... | Ian Hunneybell | Word | 0 | 10-19-2009 06:27 AM |