View Single Post
 
Old 05-27-2021, 01:02 AM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,978
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

Hmm, perhaps this will work for you.
1. Add two Date Picker Content Controls to your document. Give one the title "In" and the other one the title "Out". Format both so that they only show the time (scroll to the bottom of the format options and maybe pick h:mm:ss am/pm).
2. Add a third Plain Text Content Control and give it the title "Delta".
3. Then add the following macro to your ThisDocument module
Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
  Dim tIn As Date, tOut As Date, tDelta As Date
  tIn = ActiveDocument.SelectContentControlsByTitle("In")(1).Range.Text
  tOut = ActiveDocument.SelectContentControlsByTitle("Out")(1).Range.Text
  tDelta = tOut - tIn
  
  ActiveDocument.SelectContentControlsByTitle("Delta")(1).Range.Text = Format(tDelta, "h:mm:ss")
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote