Macropad, It did not work.
The Word document is two pages long and ends like this:
XXXX action taken by XXX personnel.
Active Directory Record already enabled. No Action Taken by XXX Personnel.
User has been updated in the Remedy System
Start Date & Time 9/22/2022 10:36:45 AM
The code I tested looks like this:
Code:
Dim oRng As Word.Range
‘Set oRng = ActiveDocument.Range
Set oRng = ActiveDocument.Paragraphs.Last.Range
ActiveDocument.Range.InsertAfter "Just After The Set" & oRng.Text
With oRng.Find
.Text = "[0-9]{1,2}\/"
.MatchWildcards = True
If .Execute Then
oRng.End = oRng.Paragraphs(1).Range.End - 1
If IsDate(oRng.Text) Then
ActiveDocument.Range.InsertAfter "It took this long: " & fcnCalcSpanStart_Finish(oRng.Text, Now)
End If
End If
End With
The output is this:
XXXX action taken by XXX personnel.
Active Directory Record already enabled. No Action Taken by XXX Personnel.
User has been updated in the Remedy System
Start Date & Time 9/22/2022 10:36:45 AM
Just After The Set
Monday, September 26, 2022 10:53:57 AM
So the new code is not finding the Date in the document.
Somehow the date and time when the code is run gets into ORng.
And the: With oRng.Find does not find the date. We know it does not find it because the If.Execute statements below it do not run.
I have the book, "Mastering VBA for Microsoft Office 2016" -Latest Version. And I cannot find anywhere that shows the way to do this.
Thanks Macrpod.