From: jerem on 27 May 2010 19:33 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, 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", 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. 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
|
Pages: 1 Prev: Anyone else? Next: How do you link VB code to a table field? |