DEV Community

Oscar Sun(孫守真字任真)
Oscar Sun(孫守真字任真)

Posted on

Answer: MS Word VBA to check for empty text form fields upon file close/exit

Yes, just write the check code in the event handler procedure Document_Close in ThisDocument object, like this

Private Sub Document_Close()
    Dim ff As FormField, sInFld As String
    For Each ff In ThisDocument.FormFields
        If ff.Result = "" Then
            Do
                sInFld = InputBox("Request date required, please fill in below.")
            Loop While sInFld

Top comments (0)