Hezakiya
02-14-2013, 10:43 AM
Happy Valentine's Day!
This code loops through all of the bookmarks in my document and saves each one as a building block in the attached template. I need to save it to the “EC Building Blocks.dotx” file in my Document Building Blocks folder.
Sub LoopAllBookmarksToMakeBBsOfBiosInOwnParagraph()
Dim oBM As Bookmark
Dim lngCount As Long
Dim r As Range
Dim objTemplate As Template
Dim objBB As BuildingBlock
Dim objName As String
For lngCount = 1 To ActiveDocument.Bookmarks.Count
Set oBM = ActiveDocument.Bookmarks(lngCount)
Set r = ActiveDocument.Bookmarks(oBM.Name).Range
objName = r.Paragraphs.First.Range
Set objTemplate = ActiveDocument.AttachedTemplate
Set objBB = objTemplate.BuildingBlockEntries.Add(Name:=objName, _
Type:=wdTypeCustom4, _
Category:="General", _
Range:=r, _
InsertOptions:=wdInsertParagraph)
Next lngCount
End Sub
Is there a way to automatically save my building blocks into the “EC Building Blocks.dotx” file in my Document Building Blocks folder? Instead of to the attached template?
Thanks very much!
This code loops through all of the bookmarks in my document and saves each one as a building block in the attached template. I need to save it to the “EC Building Blocks.dotx” file in my Document Building Blocks folder.
Sub LoopAllBookmarksToMakeBBsOfBiosInOwnParagraph()
Dim oBM As Bookmark
Dim lngCount As Long
Dim r As Range
Dim objTemplate As Template
Dim objBB As BuildingBlock
Dim objName As String
For lngCount = 1 To ActiveDocument.Bookmarks.Count
Set oBM = ActiveDocument.Bookmarks(lngCount)
Set r = ActiveDocument.Bookmarks(oBM.Name).Range
objName = r.Paragraphs.First.Range
Set objTemplate = ActiveDocument.AttachedTemplate
Set objBB = objTemplate.BuildingBlockEntries.Add(Name:=objName, _
Type:=wdTypeCustom4, _
Category:="General", _
Range:=r, _
InsertOptions:=wdInsertParagraph)
Next lngCount
End Sub
Is there a way to automatically save my building blocks into the “EC Building Blocks.dotx” file in my Document Building Blocks folder? Instead of to the attached template?
Thanks very much!