![]() |
#3
|
||||
|
||||
![]()
I agree with Andrew, however ensure that you save the building block in the document template rather than the default normal template if anyone other than yourself is to use it.You can use the following to insert your autotext building block in a bookmark.
Code:
Sub AutoTextToBM(strbmName As String, oTemplate As Template, strAutotext As String) 'Graham Mayor - https://www.gmayor.com - Last updated - 10 Apr 2019 '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 If .Bookmarks.Exists(strbmName) = True Then Set oRng = .Bookmarks(strbmName).Range Set oRng = oTemplate.AutoTextEntries(strAutotext).Insert _ (Where:=oRng, RichText:=True) .Bookmarks.Add Name:=strbmName, Range:=oRng End If 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 |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
Cray_Z | Word VBA | 7 | 01-05-2021 09:32 PM |
![]() |
MathiasFC | Word VBA | 11 | 01-14-2019 04:50 PM |
![]() |
Bob123456789 | Excel Programming | 13 | 03-14-2017 01:25 PM |
Word Macro to delete table row and table header | NorthSuffolk | Word VBA | 6 | 10-11-2016 05:04 AM |
![]() |
gsj224 | Word VBA | 3 | 07-31-2011 09:26 AM |