Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-16-2016, 11:12 PM
macropod's Avatar
macropod macropod is offline Form fields and bookmarks restrictions Windows 7 64bit Form fields and bookmarks restrictions Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

In that case, you might use something like:
Code:
Private Sub FileSave()
Call FieldCheck
End Sub
 
Private Sub Document_Close()
Call FieldCheck
End Sub
 
Private FieldCheck()
  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?", vbOKOnly
    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?", vbOKOnly
    End If
  End Select
End Sub

__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #2  
Old 04-18-2016, 06:41 AM
AttiCuS AttiCuS is offline Form fields and bookmarks restrictions Windows 7 32bit Form fields and bookmarks restrictions Office 2010 32bit
Novice
Form fields and bookmarks restrictions
 
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
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to keep formatted form fields after mail merge or replace text with formatted form fields jer85 Word VBA 2 04-05-2015 10:00 PM
Form fields and bookmarks restrictions Form updating Bookmarks - writes to the bookmarks multiple times PeterPlys Word VBA 13 01-14-2015 06:41 AM
Form fields and bookmarks restrictions How To Find Bookmarks and/or custom fields Inside Building Blocks, Office 2010 thpanos Word 3 02-17-2013 08:49 AM
Form fields and bookmarks restrictions Form Fields - Create blank form text field with if statement? LAssist2011 Word 5 12-14-2011 03:02 PM
autopopulating REF fields + bookmarks valz Word 10 09-01-2011 08:18 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:52 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft