MS Word Template Enter a date and add 1 Month

Hello,

I would like to create a Word template that will have the user enter a specific date.  Not today's date, but a specific date.  And from that specific date I need to have other dates in that form updated by 1 month, another field updated by 2 months, etc.

Can this be done? Can it be done easily without programming?  Please help. 

Thank you in advance.

|
Answer
Answer

In line with Doug's "easier" assessment and if you wish to using content controls:

Add a CC titled "Date Picked" and CCs titled Date+1M, Date+2M etc.:

Run the following in the ThisDocument module:

Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
  Select Case ContentControl.Title
    Case "Date Picked"
      If IsDate(ContentControl.Range.Text) Then
        ActiveDocument.SelectContentControlsByTitle("Date+1M").Item(1).Range.Text = _
                       Format(DateAdd("M", 1, ContentControl.Range.Text), "MMMM dd, yyyy") 'Formatted date.
        ActiveDocument.SelectContentControlsByTitle("Date+2M").Item(1).Range.Text = _
                       DateAdd("M", 2, ContentControl.Range.Text) 'Default format.
      Else
        ActiveDocument.SelectContentControlsByTitle("Date+1M").Item(1).Range.Text = vbNullString
        ActiveDocument.SelectContentControlsByTitle("Date+2M").Item(1).Range.Text = vbNullString
      End If
  End Select
lbl_Exit:
  Exit Sub
End Sub

See: http://gregmaxey.mvps.org/word_tip_pages/installing_employing_macros.html for instructions to employ the VBA code provided above.

Greg Maxey
***
Death smiles at us all, but all a man can do is smile back.


For more help with Word visit:
http://gregmaxey.com/word_tips.html

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated October 5, 2021 Views 1,102 Applies to: