Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 12-15-2023, 03:52 PM
vivka vivka is offline Selected Text when in a Table - Accessing Sentence Windows 7 64bit Selected Text when in a Table - Accessing Sentence Office 2016
Expert
 
Join Date: Jul 2023
Posts: 293
vivka is on a distinguished road
Default

Hi! 'oRng.Sentences(1).Select' works both in text and tables IF (according to my tests) there is more than one sentence in a paragraph. Note that Word has an unclear idea of a sentence, e.g.: "The book was written by J. Smith, ..." can be treated as two sentences: (1) "The book was written by J." and (2) "Smith, ..."

Keeping in mind the IF described above, you can also use:
oRng.Select
selection.Expand Unit:=wdSentence

Another method (although not a one-liner), which "doesn't care about" the IF, is:
selection.Extend
selection.Extend
selection.Extend
Note that three lines must be used: line 1 activates the extend function, line 2 extends the selection to the current word, line 3 extends the selection to the current sentence.
If you wanted to select the current paragraph, the fourth 'selection.Extend' would have to be added.
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Selected Text when in a Table - Accessing Sentence accessing avery label table in macro littlepeaks Word VBA 10 08-09-2022 12:12 PM
Selected Text when in a Table - Accessing Sentence Footnote formatting>"Apply changes to selected text" not limiting changes to selected text Swarup Word 11 07-26-2022 01:51 PM
Selected Text when in a Table - Accessing Sentence Find and Replace Selected Text or Macro for finding selected text mrplastic Word VBA 4 12-20-2019 01:25 PM
Word for Mac 2011: Problems accessing Text Boxes programmatically techy291 Word VBA 0 07-16-2017 08:41 AM
Selected Text when in a Table - Accessing Sentence Select Text in Table but Table Gets Selected Too RBusiness Word 1 06-07-2011 04:26 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:59 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