Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #6  
Old 09-26-2022, 03:10 PM
macropod's Avatar
macropod macropod is offline Range For Last Line/Paragraph - To Find Date Windows 10 Range For Last Line/Paragraph - To Find Date Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,521
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
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Range For Last Line/Paragraph - To Find Date Find and replace only paragraph marks in blank line laith93 Word 4 04-27-2022 12:18 PM
Range For Last Line/Paragraph - To Find Date 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
Range For Last Line/Paragraph - To Find Date 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

Other Forums: Access Forums

All times are GMT -7. The time now is 09:56 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft