rruckus
10-05-2010, 01:06 PM
This is a weird one. In Word 2007, I want to programmatically add Building Blocks (BB) to my template by looping through each Content Control (CC) and adding each one to the BB Galery. Everything works fine except that the paragraph style that is applied to any headings inside my CC is lost! If I look in the Building Blocks orgainzer, my block has been created but you can see that all paragraph styles are gone.
Dim objBB As BuildingBlock
Set objTemplate = ActiveDocument.AttachedTemplate
Set objBB = objTemplate.BuildingBlockEntries.Add("My BB", WdBuildingBlockTypes.wdTypeCustomQuickParts, "x4w", Selection.Range, "", WdDocPartInsertOptions.wdInsertParagraph)
Really, all I'm trying to do is reproduce the code behind Word's Insert>Quick Parts>Save Selection to Quick Part Gallery. But if I try to record the Macro to see what it's doing, the code is hidden behind a Word Basic function that still doesn't work if I call it myself: WordBasic.CreateCommonFieldBlockFromSel Description:="My CC".
Does anyone know how to programmatically add items to the Quick Parts Gallery and keep the paragraph styles???
Any ideas???
Dim objBB As BuildingBlock
Set objTemplate = ActiveDocument.AttachedTemplate
Set objBB = objTemplate.BuildingBlockEntries.Add("My BB", WdBuildingBlockTypes.wdTypeCustomQuickParts, "x4w", Selection.Range, "", WdDocPartInsertOptions.wdInsertParagraph)
Really, all I'm trying to do is reproduce the code behind Word's Insert>Quick Parts>Save Selection to Quick Part Gallery. But if I try to record the Macro to see what it's doing, the code is hidden behind a Word Basic function that still doesn't work if I call it myself: WordBasic.CreateCommonFieldBlockFromSel Description:="My CC".
Does anyone know how to programmatically add items to the Quick Parts Gallery and keep the paragraph styles???
Any ideas???