View Single Post
 
Old 12-22-2023, 04:06 PM
vivka vivka is offline Windows 7 64bit Office 2016
Expert
 
Join Date: Jul 2023
Posts: 293
vivka is on a distinguished road
Default

Also, you can try the following:
Code:
Sub LastName_2()
    ActiveDocument.range.Paragraphs(1).range.words.Last.Select
    selection.Previous(unit:=wdWord, count:=2).Select
   MsgBox selection
  End Sub
Note: instead of 'words' you can use 'Characters' in the 2nd line, which selects the unprintable paragraph sign.


Besides, you can try this one-liner:
Code:
Sub LastName_2()
    ActiveDocument.Paragraphs(1).range.words.Last.Previous(unit:=wdWord, count:=2).Select
End Sub
Reply With Quote