View Single Post
 
Old 02-09-2019, 12:39 AM
aee74 aee74 is offline Windows 10 Office 2013
Novice
 
Join Date: Feb 2019
Posts: 5
aee74 is on a distinguished road
Default

Quote:
Originally Posted by gmayor View Post
If it is not working, comment out the On Error line and see where it fails.
Still not working and no errors.

I'm doing something wrong but can't find out what it is.

Code:
Sub AutoTextToBM(strbmName As String, oTemplate As Template, strAutotext As String)
If CheckBox1 = True Then
'strBMName is the name of the bookmark to fill
'strbmname should be "bm1"
'oTemplate is the template with the autotext - probably ActiveDocument.AttachedTemplate
'oTemplate should be ActiveDocument.AttachedTemplate
'strAutotext is the name of the autotext entry
'strAutotext should be "tekstbm1"
'How to declare these values?
Dim oRng As Range
'    On Error GoTo lbl_Exit
    With ActiveDocument
        Set oRng = .Bookmarks(bm1).Range
        Set oRng = oTemplate.AutoTextEntries(tekstbm1).Insert _
                   (Where:=oRng, RichText:=True)
        .Bookmarks.Add Name:=bm1, Range:=oRng
    End With
lbl_Exit:
    Exit Sub
    End If
        'no errors, but also no text has been placed
End Sub
Attached Files
File Type: dotm test.dotm (37.8 KB, 24 views)

Last edited by aee74; 02-09-2019 at 08:53 AM. Reason: I would like to use richtext option
Reply With Quote