|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Looking for a VBA script that can locate one or more words in the same sentence
Hi,
I am trying to find a VBA script that can locate sentences that contain one or more specified words in the same sentence and then highlight those sentences or write that sentence to another Word file. I have already looked at the excellent sites maintained by Greg Maxey and Graham Mayor but could find a match. Can anyone help please? Best regards, Ravindra |
#2
|
||||
|
||||
The fundamental problem you'll have with that is that VBA has no idea what a grammatical sentence is. For example, consider the following:
Mr. Smith spent $1,234.56 at Dr. John's Grocery Store, to buy: 10.25kg of potatoes; 10kg of avocados; and 15.1kg of Mrs. Green's Mt. Pleasant macadamia nuts. For you and me, that would count as one sentence; for VBA it counts as 5 sentences.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Thank you, Paul.
Yes, sentence extraction is a problem. Greg Maxey does have this though: https://gregmaxey.com/word_tip_pages...sentences.html Best regards, Ravindra |
#4
|
||||
|
||||
Yes, but note the caveats Greg's given. As I haven't used the addin, I can't say whether it might be applied to your needs.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
Well, I hope some reasonably reliable solution is found.
|
Tags |
parser, vba, words |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Find a sentence that starts with certain words and change the style | MAHE | Word VBA | 2 | 02-26-2018 08:40 AM |
A sentence where choice words are updated when the root word changes. | Cacique | Word | 1 | 02-10-2017 10:11 AM |
Adapt a script used in Word to highlight words, to work in Outlook? | flatop | Outlook | 5 | 07-15-2014 01:07 PM |
Delete does not bring second sentence closer to first sentence | Andoheb | Word | 29 | 07-03-2014 01:48 PM |
How to mark underlined words in a sentence as A, B, C, D (beneath the words) | thudangky | Word | 13 | 12-12-2013 02:22 AM |