Share via

Microsoft Word Date Picker Content Control

Anonymous
2022-03-24T18:43:14+00:00

I have created a timesheet template for my work and used the "Date Picker Content Control" for picking the first day on a 2-week cycle. Is there a way to get the other dates to auto populate from selecting the first day?

Microsoft 365 and Office | Word | For business | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

  1. Anonymous
    2022-03-27T07:36:54+00:00

    Hmmm. To check the claim on the Microsoft site that you linked, I have changed the regional settings to English US (which changes the date format as you are undoubtedly aware) and changed the date formats of the content controls to US (easy to do with https://www.gmayor.com/insert_content_control_addin.htm - see below) and the additions from the example remain as 7 and 10 days.

    When working with content controls. it is not so much the control panel regional date format that determines the veracity of the calculation, but the format applied in the date controls' properties. In the quoted example all the dates are displayed using Date content controls. You can format those controls in any combination of UK or US English date formats and the calculations always produce the correct results as formatted regardless of regional short date setting.

    1 person found this answer helpful.
    0 comments No comments

Answer accepted by question author

  1. Jay Freedman 207.6K Reputation points Volunteer Moderator
    2022-03-26T17:06:08+00:00

    One thing to be aware of: The DateAdd function in VBA uses the date format selected in the Windows settings, as stated in this note from https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/dateadd-function :

    If the date format selected in the content control's Properties dialog uses a different order of elements than the Windows settings for regional formats, the macro may add the number of days to the "month" number instead of the "day" number. The output needs to be checked carefully.

    1 person found this answer helpful.
    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Anonymous
    2022-03-26T06:33:11+00:00

    This is easy enough to achieve with a macro saved in the ThisDocument module of the template, which then must be saved as macro enabled.

    Let's assume that you have three date content controls titled 'Start Date', 'Date 2' & 'Date 3'. The titles are irrelevant as long as they are addressed in the code. The following macro will fire when you click out of the 'Start Date' control to add 7 days for the 'Date 2' control and 10 Days for the 'Date 3' control. You can make similar calculations for as many controls as you wish.

    Option Explicit

    Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
    Dim oCC As ContentControl
    If ContentControl.Title = "Start Date" Then
    If ContentControl.ShowingPlaceholderText = False Then
    For Each oCC In ActiveDocument.ContentControls
    Select Case oCC.Title
    Case "Date 2"
    oCC.Range.Text = DateAdd("d", 7, ContentControl.Range.Text)
    Case "Date 3"
    oCC.Range.Text = DateAdd("d", 10, ContentControl.Range.Text)
    End Select
    Next oCC
    End If
    End If
    Set oCC = Nothing
    End Sub

    1 person found this answer helpful.
    0 comments No comments
  2. Anonymous
    2022-03-25T07:01:38+00:00

    Hi Willpowa23,

    Based on your description, I suppose you may need to run a macro to change some of the field. I found some thread that might help, please check the links below for reference:

    Use vba Change the dates in MS-Word ContentControl DatePicker - Microsoft Community

    Word Microsoft Office 365 - calculated date - Microsoft Community

    Besides, I would like to invite community members to this post to share any other suggestion that might help achieve the requirement.

    Kind regards,

    Neha

    0 comments No comments