![]() |
|
|
|
#1
|
|||
|
|||
|
Hi gmayor.
I tried this and it works fine if the sentence is not the last cell. But if the sentence is the last cell it returns weird characters (I think they are end of table chars). Thanks Quote:
|
|
#2
|
|||
|
|||
|
Hi, hss001! I'm repeating my answer: after finding & selecting your word use the following three lines:
Code:
selection.Extend selection.Extend selection.Extend |
|
#3
|
|||
|
|||
|
Hi, this method works perfectly in isolation. The issue is that the code I've inherited does a Find using a Selection. So, modifying the selection by extending it breaks the Find.
|
|
#4
|
|||
|
|||
|
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.
|
|
#5
|
|||
|
|||
|
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) 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. |
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
accessing avery label table in macro
|
littlepeaks | Word VBA | 10 | 08-09-2022 12:12 PM |
Footnote formatting>"Apply changes to selected text" not limiting changes to selected text
|
Swarup | Word | 11 | 07-26-2022 01:51 PM |
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 |
Select Text in Table but Table Gets Selected Too
|
RBusiness | Word | 1 | 06-07-2011 04:26 PM |