View Single Post
 
Old 11-15-2019, 06:30 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,164
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

In your Word document, put two content controls
Date Picker Content Control: give it a title of "TheDate"
Plain text Content Control: give it a title of "TheWeek"

Then in your ThisDocument module, add this code
Code:
Private Sub Document_ContentControlOnExit(ByVal aCC As ContentControl, Cancel As Boolean)
  Dim aDate As Date
  If aCC.Title = "TheDate" Then
    aDate = CDate(aCC.Range.Text)
    ActiveDocument.SelectContentControlsByTitle("TheWeek")(1).Range.Text = DatePart("ww", aDate, 2, 2)
  End If
End Sub
Then you can change the date in the TheDate CC and when you move the cursor out, the calculated result will appear in the TheWeek CC.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote