Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 03-06-2016, 10:26 PM
poetofpiano poetofpiano is offline Help Writing more Customized Command to Select Next Sentence in Microsoft Word Windows 8 Help Writing more Customized Command to Select Next Sentence in Microsoft Word Office 2013
Novice
Help Writing more Customized Command to Select Next Sentence in Microsoft Word
 
Join Date: Sep 2015
Posts: 25
poetofpiano is on a distinguished road
Default Help Writing more Customized Command to Select Next Sentence in Microsoft Word

I am very new to VBA coding but am realizing how powerful it is. To this point I have been using Autohotkey to automate Word, but it cannot handle one task I have in mind:

I want a macro that moves the insertion point to the beginning of the next sentence. Obviously the one built in to Word already is as follows:



Code:
Selection.MoveRight Unit:=wdSentence, Count:=1
But the thing I don’t like about this one is that it thinks a word like “Dr. ” or “Mr. ” or “Mrs. ” is the end of a sentence when in fact it is not. The spaces following the periods in my quotes are not an accident, because Word defines the end of a sentence as (1) a period plus a space or (2) simply a Paragraph sign (no period necessary for this second case). Thus, “A.a” would not be considered to be the end of a sentence because there is no space after the period.

So the only thing I want to change about Word’s definition of a sentence is to exclude certain words from its definition that I know are not the end of a sentence, like "Mr. " and the examples I give above. But writing this macro is proving elusive to me despite hours of trying to figure it out.

If any coding geniuses could whip up the perfect macro, that would be amazing. If not, could you help me with bits of it?

From my research, I am thinking I will have to define a Range that extends from the current insertion point position to the end of the next period plus space or the next new-paragraph sign, but not including instances such as “Dr. ” or “Mr. ” or “Mrs. ” Then I will move the insertion point from its current position to the end of that Range.

Also, from my understanding the only way to move the insertion point based on surrounding text is by using the "With Selection.Find" function, as described here. Is that true?

This has a good example of how to exclude certain characters from a search using the Find function, but again, I am at a loss to write this complex code with my current knowledge.

Thank you so much to anyone willing to help!
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Select backstage Print command programmatically NobodysPerfect Excel Programming 0 04-23-2015 08:52 AM
Select the whole sentence when a word has been modified gloos Word VBA 1 04-14-2015 10:24 PM
Help Writing more Customized Command to Select Next Sentence in Microsoft Word VBA code for Microsoft Word macro — select text and insert footnote ndnd Word VBA 10 01-06-2015 01:47 PM
Help Writing more Customized Command to Select Next Sentence in Microsoft Word Writing fractions using the Mathematics programme of Microsoft Word 2010 Microsoftenquirer1000 Word 8 11-19-2014 02:10 PM
Microsoft Word 2003: casual style from the writing box? intooutfrom Word 0 01-04-2010 01:52 PM

Other Forums: Access Forums

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