Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-07-2016, 04:12 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

Thank you so much macropod for this code, it is so close to perfect for me! I took out one line because it was starting the selection at the beginning of the sentence that the insertion point is on, whereas I want the selection to start at where the insertion point currently is (even if it is in the middle of the sentence). So now it looks like this:



Code:
    
Sub Demo()
Dim strAbbr, i As Long
    strAbbr = ".Mr.Mrs.etc."
    With Selection
      If .End < .Sentences.First.End Then .MoveEnd wdSentence, 1
      While InStr(strAbbr, "." & Trim(.Words.Last.Previous.Words.First) & ".") > 0
        .MoveEnd wdSentence, 1
      Wend
    End With
End Sub
There are only two problems with it now:

(1) First, and most importantly, if I run this macro while the insetion point is somewhere in the first sentence of a paragraph, so that the rest of the first sentence is selected, and then I run the macro a second time without doing anything else in between, the selection does not extend to the next (second) sentence in the paragraph. This is unlike the normal sentence-extend command (Selection.MoveRight Unit:=wdSentence, Count:=1, Extend:=wdExtend) which will extend the selection to the next sentence each time the command is run.

(2) Second, if I run this macro while the insetion point is in a ONE-sentence paragraph and the next line directly below this one-sentence paragraph has no text (i.e., it’s just a blank line with a Paragraph sign), the selection will extend down to also include the Paragraph sign of this second line. It would ideally stop after the first line and not select anything on the second line below. Strangely, the selection does stop immediately after the first sentence of a one-sentence paragraph if the very next line directly below does have some text.

If you could help me iron out these two issues, I would be infinitely grateful. I am even willing to pay someone to do this, it is that important to me to find an answer. I have tried understanding what needs to be changed, but it is over my head, as I couldn’t find documentation on the internet for some of the phrases your code uses.

And thank you gmaxey for your suggestion. I loaded that Add-in, but unfortunately it only selects entire sentences, and I can’t examine its coding. But I am very glad to see that I am not the only one who wants to do something like this!
Reply With Quote
Reply



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 05:19 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