J
Jake
I have a form that accepts AutoText entries. If the AutoText entry doesn't
exist I prompt the user with an Inputbox function to enter the entry again.
But there is a line that deletes the previous entry: Selection.Delete. If
the user keeps entering the wrong AutoText entry more is deleted than is
required.
Here is sample code that runs when user clicks OK on form:
On Error Resume Next
Dim x As String
Dim y As String
Selection.GoTo What:=wdGoToBookmark, Name:="MyTest"
Selection.Text = frmAutoTextTest.txtFirstAutoText
Selection.Range.InsertAutoText
Do While Err.Number <> 0
Err.Number = 0
Selection.Delete
frmAutoTextTest.txtFirstAutoText.SetFocus
frmAutoTextTest.txtFirstAutoText = ""
x = InputBox("Enter First AutoText again", "Re-enter AutoText")
Selection.Text = x
If x = vbCancel Then
Exit Sub
End If
Selection.Range.InsertAutoText
Loop
frmAutoTextTest.txtSecondAutoText.SetFocus
Selection.GoTo What:=wdGoToBookmark, Name:="AnotherTest"
Selection.Text = frmAutoTextTest.txtSecondAutoText
Selection.Range.InsertAutoText
Do While Err.Number <> 0
Err.Number = 0
Selection.Delete
frmAutoTextTest.txtSecondAutoText.SetFocus
frmAutoTextTest.txtSecondAutoText = ""
y = InputBox("Enter Second AutoText again", "Re-enter AutoText")
Selection.Text = x
If x = vbCancel Then
Exit Sub
End If
Selection.Range.InsertAutoText
Loop
Unload Me
Thanks for any help,
Jake
exist I prompt the user with an Inputbox function to enter the entry again.
But there is a line that deletes the previous entry: Selection.Delete. If
the user keeps entering the wrong AutoText entry more is deleted than is
required.
Here is sample code that runs when user clicks OK on form:
On Error Resume Next
Dim x As String
Dim y As String
Selection.GoTo What:=wdGoToBookmark, Name:="MyTest"
Selection.Text = frmAutoTextTest.txtFirstAutoText
Selection.Range.InsertAutoText
Do While Err.Number <> 0
Err.Number = 0
Selection.Delete
frmAutoTextTest.txtFirstAutoText.SetFocus
frmAutoTextTest.txtFirstAutoText = ""
x = InputBox("Enter First AutoText again", "Re-enter AutoText")
Selection.Text = x
If x = vbCancel Then
Exit Sub
End If
Selection.Range.InsertAutoText
Loop
frmAutoTextTest.txtSecondAutoText.SetFocus
Selection.GoTo What:=wdGoToBookmark, Name:="AnotherTest"
Selection.Text = frmAutoTextTest.txtSecondAutoText
Selection.Range.InsertAutoText
Do While Err.Number <> 0
Err.Number = 0
Selection.Delete
frmAutoTextTest.txtSecondAutoText.SetFocus
frmAutoTextTest.txtSecondAutoText = ""
y = InputBox("Enter Second AutoText again", "Re-enter AutoText")
Selection.Text = x
If x = vbCancel Then
Exit Sub
End If
Selection.Range.InsertAutoText
Loop
Unload Me
Thanks for any help,
Jake