View Single Post
 
Old 01-06-2021, 03:47 AM
gmaxey gmaxey is online now Windows 10 Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

Graham,


Why the loop?

Code:
Sub AutoTextToCC(strCCName As String, oTemplate As Template, strAutotext As String)
'Graham Mayor - https://www.gmayor.com - Last updated - 10 Apr 2019
'strCCName is the ContentControl title
'oTemplate is the template with the autotext entry
'strAutotext is the name of the autotext entry
Dim oCC As ContentControl
  On Error GoTo lbl_Exit
  Set oCC = ActiveDocument.SelectContentControlsByTitle(strCCName).Item(1)
  oCC.LockContentControl = True
  oTemplate.AutoTextEntries(strAutotext).Insert Where:=oCC.Range, RichText:=True
lbl_Exit:
  Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote