View Single Post
 
Old 04-26-2018, 06:35 AM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,138
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Frankly you can insert building blocks anywhere practical. If you want to insert a sequernce of building blocks at a range then try the following function

Code:
Sub AutoTextToRange(oRng As Range, oTemplate As Template, strAutotext As String)
'oRng is the name of the range to Place
'oTemplate is the template with the autotext - probably ActiveDocument.AttachedTemplate
'strAutotext is the name of the autotext entry
    Set oRng = oTemplate.AutoTextEntries(strAutotext).Insert _
               (Where:=oRng, RichText:=True)
    oRng.Collapse 0
    oRng.Select
lbl_Exit:
    Exit Sub
End Sub
You can call that as many times as you have building blocks to insert. Each time it puts the selection at the end of the building block. The following puts two building blocks consecutively at the cursor.

You could instead insert the first one at a range and the rest will follow.

Code:
AutoTextToRange Selection.Range, ActiveDocument.AttachedTemplate, "BBName1"
AutoTextToRange Selection.Range, ActiveDocument.AttachedTemplate, "BBName2"
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote