![]() |
|
#1
|
|||
|
|||
|
My friends, from years ago, this forum helped me with the code below. In the Word Document, It finds a date in a format like this: 9/24/2022 10:04:36 AM It works great. But now there is more than one date in the document. So I want it to find only the date on the last line of the document, the last paragraph. How can I change this to find the date in the last line/paragraph of the document? This is the old code: Code:
Dim oRng As Word.Range
Set oRng = ActiveDocument.Range
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
Last edited by macropod; 09-24-2022 at 03:26 PM. Reason: Added code tags |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Find and replace only paragraph marks in blank line
|
laith93 | Word | 4 | 04-27-2022 12:18 PM |
How to resize a paragraph range to include just a single line of text
|
Peterson | Word VBA | 5 | 07-08-2019 04:36 PM |
| Using DateValue to find if a date exists within a certain range | OfficeAssociate99 | Excel Programming | 3 | 07-13-2017 11:06 AM |
Find if Date range falls within another range
|
Triadragon | Excel | 3 | 05-02-2016 11:48 AM |
| Find a Date in a Range | rspiet | Excel | 3 | 02-15-2016 08:37 AM |