J
jerem
I have a form and I am using the following code to test if a check box is
checked and if so, to insert Autotext. Everything works fine, however, right
after the autotext is inserted I would like the cursor to return to the first
fill in formfield of the autotext just inserted. Right now, it is going to
the next fillin formfield after the checkbox. I've tried various code after
the line ".AttachedTemplate.AutoTextEntries(ATEntryName).Insert myRange,
True" and after the line InsertATEntry "Check1", "MoreClientInfo", True, but
have had no luck. I'm right now scouring the internet for solutions, but if
anybody can answer this I would greatly appreciate it. Please note, I need
to retain the Check1 Bookmark for a marker as to where to put the Autotext so
I can't mess with that (or at least that’s my thinking). Thanks for your
help.
Sub AdditionalClientList()
'
Dim ffname As String
ffname = Selection.FormFields(1).Name
With ActiveDocument
.Unprotect
If .FormFields(ffname).CheckBox.Value = True Then
InsertATEntry "Check1", "MoreClientInfo", True
Else
.Protect wdAllowOnlyFormFields, noreset
Exit Sub
End If
.Protect wdAllowOnlyFormFields, noreset
End With
End Sub
Public Sub InsertATEntry(BkmkName As String, ATEntryName As String, Optional _
bRestoreBkmk As Boolean = False)
With ActiveDocument
If .Bookmarks.Exists(BkmkName) = True Then
Dim myRange As Range
Set myRange = .Bookmarks(BkmkName).Range
On Error GoTo ATEError
.AttachedTemplate.AutoTextEntries(ATEntryName).Insert myRange,
True
.FormFields("Check1").CheckBox.Value = False
If bRestoreBkmk = True Then .Bookmarks.Add BkmkName, myRange
Else: MsgBox "Cannot find the bookmark " & BkmkName & "."
End If
End With
Exit Sub
ATEError:
MsgBox "The required AutoText entry " & ATEntryName & " could not be
found.", _
vbCritical, "AutoText Error"
End Sub
checked and if so, to insert Autotext. Everything works fine, however, right
after the autotext is inserted I would like the cursor to return to the first
fill in formfield of the autotext just inserted. Right now, it is going to
the next fillin formfield after the checkbox. I've tried various code after
the line ".AttachedTemplate.AutoTextEntries(ATEntryName).Insert myRange,
True" and after the line InsertATEntry "Check1", "MoreClientInfo", True, but
have had no luck. I'm right now scouring the internet for solutions, but if
anybody can answer this I would greatly appreciate it. Please note, I need
to retain the Check1 Bookmark for a marker as to where to put the Autotext so
I can't mess with that (or at least that’s my thinking). Thanks for your
help.
Sub AdditionalClientList()
'
Dim ffname As String
ffname = Selection.FormFields(1).Name
With ActiveDocument
.Unprotect
If .FormFields(ffname).CheckBox.Value = True Then
InsertATEntry "Check1", "MoreClientInfo", True
Else
.Protect wdAllowOnlyFormFields, noreset
Exit Sub
End If
.Protect wdAllowOnlyFormFields, noreset
End With
End Sub
Public Sub InsertATEntry(BkmkName As String, ATEntryName As String, Optional _
bRestoreBkmk As Boolean = False)
With ActiveDocument
If .Bookmarks.Exists(BkmkName) = True Then
Dim myRange As Range
Set myRange = .Bookmarks(BkmkName).Range
On Error GoTo ATEError
.AttachedTemplate.AutoTextEntries(ATEntryName).Insert myRange,
True
.FormFields("Check1").CheckBox.Value = False
If bRestoreBkmk = True Then .Bookmarks.Add BkmkName, myRange
Else: MsgBox "Cannot find the bookmark " & BkmkName & "."
End If
End With
Exit Sub
ATEError:
MsgBox "The required AutoText entry " & ATEntryName & " could not be
found.", _
vbCritical, "AutoText Error"
End Sub