antman2988
Board Regular
- Joined
- Jun 28, 2018
- Messages
- 78
Hello!
I am attempting to use the BeforeSave event to check whether any of the checkboxes are selected before allowing the user to save the workbook. Please see my code below.
I'm still able to save the workbook even when none of the checkboxes are selected. What is the issue with my code?
Any help is appreciated. Thanks!
-Anthony
I am attempting to use the BeforeSave event to check whether any of the checkboxes are selected before allowing the user to save the workbook. Please see my code below.
VBA Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
MsgBox "Entered Sub Workbook_BeforeSave"
If Application.Sheets("Assign_FI$Cal_Project_Code").Shapes("Check Box 179").ControlFormat.Value = 0 Or Application.Sheets("Assign_FI$Cal_Project_Code").Shapes("Check Box 180").ControlFormat.Value = 0 Or Application.Sheets("Assign_FI$Cal_Project_Code").Shapes("Check Box 181").ControlFormat.Value = 0 Or Application.Sheets("Assign_FI$Cal_Project_Code").Shapes("Check Box 182").ControlFormat.Value = 0 Or Application.Sheets("Assign_FI$Cal_Project_Code").Shapes("Check Box 183").ControlFormat.Value = 0 Or Application.Sheets("Assign_FI$Cal_Project_Code").Shapes("Check Box 187").ControlFormat.Value = 0 Or Application.Sheets("Assign_FI$Cal_Project_Code").Shapes("Check Box 185").ControlFormat.Value = 0 Or Application.Sheets("Assign_FI$Cal_Project_Code").Shapes("Check Box 186").ControlFormat.Value = 0 Then
Cancel = True
MsgBox "Save cancelled. Please choose an option in Section 10."
End If
End Sub
I'm still able to save the workbook even when none of the checkboxes are selected. What is the issue with my code?
Any help is appreciated. Thanks!
-Anthony