View Single Post
 
Old 04-18-2016, 06:41 AM
AttiCuS AttiCuS is offline Windows 7 32bit Office 2010 32bit
Novice
 
Join Date: Mar 2016
Posts: 6
AttiCuS is on a distinguished road
Default

Hi macropod,

Thank you for an example.

However, it was not my intend.

Now I saved my file as Microsoft Word Macro-Enabled Template.

I want to use vbYesNoCancel buttons.

But, I don't know how to assign each button. When someone choose 'Yes' the macro should let save the file, even if clicked 'Save' - little disk in left upper corner or want to close the file by pressing 'X'. But, if someone choose 'No' or 'Cancel' should go back to file with possible to continue filling the form. So won't get system question 'Do you want to save changes you made to...'.

Code:
Private Sub Document_Close()
  Select Case ActiveDocument.FormFields("drop").Result
    Case "Internal"
    If ActiveDocument.FormFields("mob_ph_check").CheckBox.Value = False And ActiveDocument.FormFields("broad_check").CheckBox.Value = False And ActiveDocument.FormFields("car_check").CheckBox.Value = False And ActiveDocument.FormFields("vsp_check").CheckBox.Value = False Then
        MsgBox "Are you sure that contract should be without benefits?", vbYesNoCancel
        Cancel = True
    End If
    Case "Permanent"
    If ActiveDocument.FormFields("mob_ph_check").CheckBox.Value = False And ActiveDocument.FormFields("broad_check").CheckBox.Value = False And ActiveDocument.FormFields("car_check").CheckBox.Value = False And ActiveDocument.FormFields("vsp_check").CheckBox.Value = False Then
        MsgBox "Are you sure?", vbYesNoCancel
        Cancel = True
    End If
  End Select
End Sub
 
Sub FileSave()
Call Document_Close
End Sub
Reply With Quote