regex - Search for sentences in a MSWord document using vba but doesn't work if a number is in the sentence -


i realize vba not #s hence i’m struggling code.

do   'find next sentence starting @ end of last sentence   selection.find.text = "[^13.\?\!]{1}[!.\?\!^13]@[.\!\?]{1}"   selection.find.execute    oldvalue = selection.start  'this loop control    'remove punctuation @ beginning of sentence (that last sentence   selection.find.text = "<*>*[.\!\?]{1}"   selection.find.execute   if instr(1, selection.text, findword, vbtextcompare) > 0        'save sentence   end if    selection.collapse wdcollapseend   selection.moveleft wdcharacter, 1, false  loop while breakloop 

my problem first execute gets screwy when hits sentence # in it. , selection.start becomes 0 (anytime hits sentence has # in it).

any ideas? i’m thinking of putting on stackoverflow.

huzzah, found answer ....

using microsoft vbscript regular expressions 5.5 (from tools --> references menu) able go through text #s using activedocument.sentences

 each s in activedocument.sentences   next s 

it's still little buggy - not ".," in "e.g.," doesn't recognize sentence in or if have "some text e.g. more text." breaks "some text e.g." , "some more text"

i made comment in macro prep text remove ., because overall works well.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -