I have a document template that uses form fields. Some of the fields are required so I need to use the 'BeforeSave' event to open a msgbox advising user to fill in the fields, then do not save the document and exit sub.
I have the following code:
Private Sub appWord_DocumentBeforeSave(ByVal Doc As Document, SaveAsUI As Boolean, Cancel As Boolean)
Dim pc As DropDown
Set pc = ActiveDocument.FormFields("ProfitCenter").DropDown
If pc.Value = 1 Then
Set Doc = ActiveDocument
MsgBox "You have not filled out some required fields." & Chr(10) & "You cannot" & _
"save your work until you do." & Chr(10) & "Please review and complete the form before saving."
SaveAsUI = False
Cancel = True
End If
End Sub
I have tried to follow the steps in the help titled 'Using Events with the Application Object' but cannot get this to kick off on the 'save' event.
I have the following code:
Private Sub appWord_DocumentBeforeSave(ByVal Doc As Document, SaveAsUI As Boolean, Cancel As Boolean)
Dim pc As DropDown
Set pc = ActiveDocument.FormFields("ProfitCenter").DropDown
If pc.Value = 1 Then
Set Doc = ActiveDocument
MsgBox "You have not filled out some required fields." & Chr(10) & "You cannot" & _
"save your work until you do." & Chr(10) & "Please review and complete the form before saving."
SaveAsUI = False
Cancel = True
End If
End Sub
I have tried to follow the steps in the help titled 'Using Events with the Application Object' but cannot get this to kick off on the 'save' event.