View Single Post
 
Old 12-22-2023, 03:45 PM
vivka vivka is offline Windows 7 64bit Office 2016
Competent Performer
 
Join Date: Jul 2023
Posts: 228
vivka is on a distinguished road
Default

Hi, RobiNew, your macro with my minor modifications is good :
Code:
Sub LastName()
Set orng = ActiveDocument.range
orng.Collapse
orng.MoveStartUntil Cset:=Chr(13)
orng.Collapse wdCollapseEnd
orng.Previous(Unit:=wdWord, count:=2).Select
MsgBox selection
End Sub
The code works without problems if the first paragraph's last lettered word is followed only by a period, any number (incl. zero) of spaces and VbCr.
Reply With Quote