T
Tait Milliken
I have a Word 2000 document with several FormFields. These
fields will ultimately be used to populate an Access
database after several documents have been created from
the template. Since the loading of the Access db takes
place separately, I need to perform as much editing as
possible within the Word document. I have written several
macros that are invoked on exit from most FormFields where
editing is needed. My problem is that I cannot get the
FormField that had the error to be reselected. Consider
the following code:
Sub Validate_ITLExtension()
'
' This macro ensures that the ITL telphone extension is
five digits long with
' a leading "3"
'
Dim szExtension As String
szExtension = ActiveDocument.FormFields
("txtITLExt").Result
If Not (Len(szExtension) = 5 And Mid$(szExtension, 1, 1)
= "3") Then
MsgBox "Extensions must be five digits including a
leading ""3""", vbOKOnly And vbExclamation, "Telephone
Extension Error"
ActiveDocument.FormFields("txtITLExt").Result = ""
ActiveDocument.Bookmarks("txtITLExt").Select
End If
End Sub
The errors are properly trapped but the .select is
apparently ignored and the next FormField is activated.
I have tried using
Selection.GoTo What:=wdGoToBookmark, Name="txtITLExt"
but it doesn't work either.
Suggestions?
fields will ultimately be used to populate an Access
database after several documents have been created from
the template. Since the loading of the Access db takes
place separately, I need to perform as much editing as
possible within the Word document. I have written several
macros that are invoked on exit from most FormFields where
editing is needed. My problem is that I cannot get the
FormField that had the error to be reselected. Consider
the following code:
Sub Validate_ITLExtension()
'
' This macro ensures that the ITL telphone extension is
five digits long with
' a leading "3"
'
Dim szExtension As String
szExtension = ActiveDocument.FormFields
("txtITLExt").Result
If Not (Len(szExtension) = 5 And Mid$(szExtension, 1, 1)
= "3") Then
MsgBox "Extensions must be five digits including a
leading ""3""", vbOKOnly And vbExclamation, "Telephone
Extension Error"
ActiveDocument.FormFields("txtITLExt").Result = ""
ActiveDocument.Bookmarks("txtITLExt").Select
End If
End Sub
The errors are properly trapped but the .select is
apparently ignored and the next FormField is activated.
I have tried using
Selection.GoTo What:=wdGoToBookmark, Name="txtITLExt"
but it doesn't work either.
Suggestions?