Results 1 to 20 of 25

Thread: Solved: Running macro on word document close, stopping close

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Mentor OTWarrior's Avatar
    Joined
    Aug 2007
    Location
    England
    Posts
    389
    Location

    Solved: Running macro on word document close, stopping close

    I am trying to put some data checking into a word document to check for a formfield value, and if the formfield is empty, but only on document close

    with the warning I need it to prompt the user, and to not allow closure of the document until this field is filled in.

    I have the code to do the check, and to give the warning message, but don't know how to stop closing the document.

    Here's what I have:

    [vba]Private Sub Document_Close()

    With ActiveDocument
    If .FormFields("chkMale").CheckBox.Value = False And _
    .FormFields("chkFemale").CheckBox.Value = False Then
    MsgBox "Please say what gender this person is", vbInformation, "~Missing Info~"
    Exit Sub 'I thought this would do it, but obviously not
    Else
    MsgBox "'Tis Fine!",vbinformation,"Title"
    End If
    End With

    End Sub[/vba]
    Last edited by OTWarrior; 06-12-2008 at 01:42 AM. Reason: spelling in title
    -Once my PC stopped working, so I kicked it......Then it started working again

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •