02-10-2019, 03:39 AM
|
Novice
|
|
Join Date: Feb 2019
Posts: 5
|
|
Quote:
Originally Posted by Guessed
You have posted a sub with input variables which means this macro can't be run directly, it has to be passed some extra information in order to run). The sub also needs modification in order to use the variables that it expects to be passed in. To run it, you need a separate subroutine which passes in the variables and also to fix the function. Try
Code:
Sub Test_AutoTextToBM()
AutoTextToBM strbmName:="bm1", oTemplate:=ActiveDocument.AttachedTemplate, strAutotext:="tekstbm1"
End Sub
Sub AutoTextToBM(strbmName As String, oTemplate As Template, strAutotext As String)
'If CheckBox1 = True Then
Dim oRng As Range
On Error GoTo lbl_Exit 'will avoid errors if bookmark doesn't exist or AT doesn't exist in attached template
Set oRng = ActiveDocument.Bookmarks(strbmName).Range
Set oRng = oTemplate.AutoTextEntries(strAutotext).Insert(Where:=oRng, RichText:=True)
ActiveDocument.Bookmarks.Add Name:=strbmName, Range:=oRng
lbl_Exit:
Exit Sub
'End If
End Sub
|
It works. Great. Thanks
|