Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 02-23-2018, 01:43 PM
macropod's Avatar
macropod macropod is online now Find a sentence that starts with certain words and change the style Windows 7 64bit Find a sentence that starts with certain words and change the style Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,366
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Unless you're proposing the change the Style of the whole paragraph, you will have trouble with having Word identify a sentence. That's because 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.

If you're trying to change the Style of the whole paragraph, you can use a wildcard Find/Replace where, for example:
Find = State Community Name:*^13
Replace = ^&
And you set the Replacement Style to Heading1. No macros required.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
 

Tags
styles, vba



Similar Threads
Thread Thread Starter Forum Replies Last Post
Find a sentence that starts with certain words and change the style A sentence where choice words are updated when the root word changes. Cacique Word 1 02-10-2017 10:11 AM
How to use find and replace to change text to a custom style wrdy Word 7 03-11-2014 12:09 AM
Find instance of a word in a specific style and change its color hwg Word VBA 7 02-20-2014 10:59 PM
Find a sentence that starts with certain words and change the style 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
Find and replace multiple documents change style BaPW Word 0 08-14-2011 11:12 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:21 AM.


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