View Single Post
 
Old 09-26-2022, 03:10 PM
macropod's Avatar
macropod macropod is offline Windows 10 Office 2016
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

Your latest code isn't the same as what you posted the first time. This line:
ActiveDocument.Range.InsertAfter "Just After The Set" & oRng.Text
inserts content after the range you just defined with:
Set oRng = ActiveDocument.Paragraphs.Last.Range
Hence, oRng no longer points to the last paragraph!
Your code should be something like:
Code:
With ActiveDocument.Range
  .InsertAfter vbCr & "Just After The Set " & .Paragraphs.Last.Range.Text
  With .Find
    .Text = "[0-9]{1,2}/[0-9]{1,2}/[0-9]{4}"
    .MatchWildcards = True
    .Execute
    .Forward = False
  End With
  If .Find.Found = True Then
    .End = .Paragraphs.Last.Range.End - 1
    If IsDate(.Text) Then ActiveDocument.Range.InsertAfter "It took this long: " & fcnCalcSpanStart_Finish(oRng.Text, Now)
  End If
End With
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote