![]() |
#2
|
||||
|
||||
![]()
The following function will insert a building block from a named template at a bookmarked location. That bookmark can be in a footer. See also thew example at https://www.gmayor.com/word_vba_examples_3.htm
Code:
Sub AutoTextToBM(strbmName As String, oTemplate As Template, strAutotext As String) 'strBMName is the name of the bookmark to fill 'oTemplate is the template with the autotext - probably ActiveDocument.AttachedTemplate 'strAutotext is the name of the autotext entry Dim oRng As Range On Error GoTo lbl_Exit With ActiveDocument Set oRng = .Bookmarks(strbmName).Range Set oRng = oTemplate.AutoTextEntries(strAutotext).Insert _ (Where:=oRng, RichText:=True) .Bookmarks.Add Name:=strbmName, Range:=oRng End With lbl_Exit: Exit Sub End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
Tags |
building block, footer and header, vba |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
VBA Word - Building Block (AutoText) - Array - Replace Text with Specific Building Blocks | jc491 | Word VBA | 7 | 01-03-2016 10:34 PM |
Building blocks show correctly in dropdown, but wrong building block populates in doc | wordgirl123 | Word | 0 | 10-03-2013 08:30 AM |
INSERT building blocks from Quickpart in word | jasserin | Word VBA | 0 | 06-05-2013 12:55 PM |
Word - Attach Building Blocks | namedujour | Word | 0 | 04-04-2011 09:59 AM |
Word 2007 Building Blocks - difficult to update... | Ian Hunneybell | Word | 0 | 10-19-2009 06:27 AM |