Thank you macropod for your support.
Yes, "Date of Initiation" is a Date Picker Content Control
The field that is supposed to add 30 days from date of initiation is called "Due Date".
I am not sure what should be the "Due Date" field type. I added a Rich Text Content Control (I am not sure if this should be another field type). So I changed the code to this:
Code:
Private Sub Document_ContentControlOnExit(ByVal CCtrl As ContentControl, Cancel As Boolean)
Application.ScreenUpdating = False
Dim Dt As Date, StrDt As String
With CCtrl
If .Title <> "Date of Initiation" Then Exit Sub
If .ShowingPlaceholderText = True Then
ActiveDocument.SelectContentControlsByTitle("Due Date")(1).Range.Text = ""
Else
StrDt = .Range.Text
If IsDate(StrDt) Then
Dt = CDate(StrDt)
Else
Dt = CDate(Split(StrDt, (Split(StrDt, " ")(0)))(1))
End If
ActiveDocument.SelectContentControlsByTitle("Due Date")(1).Range.Text = Format(Dt + 30, .DateDisplayFormat)
End If
End With
Application.ScreenUpdating = True
End Sub
The problem now is that there is no macro to run. I am sorry If I missed something.
Also, can the due date field be automatically calculated without having to run a macro?