View Single Post
 
Old 06-10-2016, 12:00 AM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,137
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

The macro should prompt when any of the listed check boxes is unchecked. If all the listed check boxes must be checked before printing then instead of giving the user a choice, the warning can simply cancel the print process. e.g. change the main code to the following.

I don't get the failure to trigger the prompt on successive attempts at printing, with this code, assuming one of more of the named check boxes is unchecked. If they are all checked the document is printed.

Code:
Option Explicit
Public WithEvents appWord As Word.Application

Private Sub appWord_DocumentBeforePrint _
        (ByVal Doc As Document, _
         Cancel As Boolean)
Dim intResponse As Integer
Dim sBox As String: sBox = ""
    Select Case False
        Case ThisDocument.CheckBox1.Value: sBox = "CheckBox 1"
        Case ThisDocument.CheckBox2.Value: sBox = "CheckBox 2"
        Case ThisDocument.CheckBox3.Value: sBox = "CheckBox 3"
    End Select
    If Not sBox = "" Then
        intResponse = MsgBox(sBox & " has not been checked!", vbCritical)
        If intResponse = vbOK Then Cancel = True
    End If
lbl_Exit:
    Exit Sub
End Sub
Note you can use more meaningful check box names and/or messages associates with each box.
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote