View Single Post
 
Old 11-02-2022, 06:10 AM
CellCharger CellCharger is offline Windows 10 Office 2019
Novice
 
Join Date: Oct 2021
Location: NJ, USA
Posts: 24
CellCharger is on a distinguished road
Default

Thank you Graham for your response.

This is the existing macro. It adds 30 days in the due date field . I am not sure but it looks it it disappeared when I saved the file as DOCX.

Code:
Option Explicit

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
I also uploaded a macro enabled test form in the original post.

Last edited by CellCharger; 11-02-2022 at 09:36 AM.
Reply With Quote