View Single Post
 
Old 01-04-2024, 08:08 AM
hss001 hss001 is offline Windows 10 Office 2021
Novice
 
Join Date: Dec 2023
Posts: 20
hss001 is on a distinguished road
Default

Ideally, I want to "select" the "sentence" of the selected text - this will work without needing to modify any other code.

So the below line works fine, EXCEPT when the text is in a table and also the last row - as it picks up end of row characters.

Code:
sStringVariable = oWordApp.Selection.Sentences(1)
@gmayor's code - it doesn't appear to work correctly, in that it doesn't detect if the cell is in the last row.

So, all I need to do is detect if the selection is in the last row of a table, and then strip off the last 2 chars.




Quote:
Originally Posted by vivka View Post
hss001, do you want the code to msgbox, select or highlite the found sentence(s)? If the found senetence is selected the original selection will be always broken. Sorry, but I don't quite understand your aim.
Reply With Quote