Hi TechWriter,
A macro could be used to do this but, if the user's security settings are too high, or the users elects to disable macros in the
document, then the macro approach won't work. The following macro, when placed in the document's ‘ThisDocument’ module, prevents the
document being closed if it contains any formfields that have not been filled in:
Private Sub Document_Close()
Dim aField As FormField
For Each aField In ActiveDocument.FormFields
If Trim(aField.Result) = "" Then
MsgBox "Please complete all the items"
ThisDocument.Reload
Exit Sub
End If
Next aField
End Sub
You can the following version to check a specific formfield by referencing the field's bookmark name (assuming you've set its
properties to create one):
Private Sub Document_Close()
If Trim(ActiveDocument.Bookmarks("BkMrk").Range.Text) = "" Then
MsgBox "Please complete the nominated item."
'ThisDocument.Reload
Exit Sub
End If
End Sub
where 'BkMrk' is the name of the bookmark. Change the message to suit.
Cheers