View Single Post
 
Old 09-18-2017, 02:44 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Doing this would entail writing an application event procedure, for which see: https://wordmvp.com/FAQs/MacrosVBA/AppClassEvents.htm
and adding that to your document's template.

Once you've done the basic setup, you'd insert the following code into the class module:
Code:
Private Sub oApp_WindowSelectionChange(ByVal Sel As Selection)
If Sel.Information(wdWithInTable) <> True Then Exit Sub
If Sel.Tables(1).Range <> ActiveDocument.Tables(1).Range Then Exit Sub
Dim r As Long, c As Long
Application.ScreenUpdating = False
With Sel
  r = .Cells(1).RowIndex
  With .Tables(1)
    If Len(.Cell(r, 1).Range.Text) > 2 Then Exit Sub
    If r > 1 Then
      If Len(.Cell(r - 1, 1).Range.Text) = 2 Then Exit Sub
      If Len(.Cell(r - 1, 2).Range.Text) = 2 Then Exit Sub
    End If
    .Cell(r, 1).Range.Text = Format(Now(), "hh:mm:ss")
  End With
End With
Application.ScreenUpdating = True
End Sub
As coded, the macro will only insert the timestamp into the first column of the first table in the document. After the first row, it triggers only if the first two cells of the preceding row have content.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote