Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 02-07-2019, 03:54 AM
gmayor's Avatar
gmayor gmayor is offline Userform selectbox to insert autotext Windows 10 Userform selectbox to insert autotext Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,144
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

The code I posted in the linked thread does work, provided you identify the autotext location correctly and apply the correct names for the autotext entry and the bookmark.



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
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
insert Autotext via button only from specified category lodi123 Word VBA 0 07-26-2017 02:57 AM
Userform selectbox to insert autotext How do I programmatically insert and append the text from AutoText 0002 to the end of the existing t erik816 Word VBA 1 03-09-2016 12:48 AM
UserForm of Autotext Entries ptmuldoon Word VBA 11 02-13-2016 09:36 AM
Userform selectbox to insert autotext How do i insert autotext using a contol toolbox checkbox NP85 Word VBA 12 02-09-2014 03:06 PM
Userform selectbox to insert autotext Insert identifiers in AutoText snippet. Microsoft word deepgreen Word 13 01-21-2014 05:16 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:02 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft