assigning key to move next/prev sentence

D

dStum

Hi, I'd like to programmatically assign keys that move to previous sentence
and next sentence. Any suggestions?

Thanks!
Doug
 
G

Greg Maxey

I suppose you could assign a pair of macros to a keyboard shortcut.
Something like:

Sub SelNextSen()
If Selection.Sentences(1) <> ActiveDocument.Sentences.Last Then
Selection.Next(Unit:=wdSentence, Count:=1).Select
Selection.MoveEnd Unit:=wdCharacter, Count:=-1
Else
ActiveDocument.Sentences.First.Select
Selection.MoveEnd Unit:=wdCharacter, Count:=-1
End If
End Sub

Sub SelPrevSen()
If Selection.Sentences(1) <> ActiveDocument.Sentences.First Then
Selection.Previous(Unit:=wdSentence, Count:=1).Select
Selection.MoveEnd Unit:=wdCharacter, Count:=-1
Else
ActiveDocument.Sentences.Last.Select
Selection.MoveEnd Unit:=wdCharacter, Count:=-1
End If
End Sub

See: http://word.mvps.org/FAQs/Customization/AsgnCmdOrMacroToHotkey.htm
 
D

dStum

thanks! how would I assign the subs to the keys using VB, is that possible?
(e.g. instead of using the macro interface. does that make sense?)
 
G

Greg Maxey

dStum,

I don't understand your question. I thought that you wanted a keyboard
shortcut to move from the current sentence to the next or from the current
sentence to the previous. The macros that I provided can be assigned to any
keyboard shortcut using the method in the link I posted. I don't know how
you could make the actually assignments with VBA.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top