-
Private Sub DocumentBeforeClose(ByVal Doc As Document, Cancel As Boolean)
Dim intResponse As Integer
Dim FFld As FormField
Dim allFieldsCompleted As Boolean
allFieldsCompleted = True
For Each FFld In Doc.FormFields
If Trim(FFld.Result) = "" Then
intResponse = MsgBox("Please enter a value in each field", vbOKOnly)
allFieldsCompleted = False
Exit For ' Exits the loop immediately after finding an incomplete field
EndIf
next
If Not allFieldsCompleted Then
Cancel = True ' Prevents the document from closing when there are incomplete fields
EndIf
End Sub
With this change, the document will not close if any fields are not completed. The user will receive a warning and can continue to update required fields before closing the document.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules