shift-end in outline view selects *whole* paragraph -- prevent?

G

Guest

Greetings --

I am using Word 2003. I instinctively press shift-end when I want to select
from the current cursor position to the end of the current line.

The problem that I'm encountering is that in Outline view (which I'm using
increasingly these days), if I happen to be on the last line of a paragraph,
pressing shift-end results in selection of the *entire paragraph.* This is
pretty counterintuitive and bothersome for me (muscle memory dies hard).

Is there a way to prevent this, so I can select from cursor-to-end-of-line
even if I happen to be on the last line of a paragraph in outline-view?

Thanks!
--Will
 
G

Guest

In general, selection of text seems to work a bit differently in Outline View
than in other views. The only solution I have found to the problem you
describe is using a macro.

After some experiments, I found that the following little macro seems to do
what you want (in any view): it extends the selection to the end of the
current line no matter which line in a paragraph.

Sub SelectToEndOfLine()
Selection.MoveEnd unit:=wdLine, Count:=1
End Sub

You could install the macro and assign a keyboard shortcut to it.

For help on installing a macro, see:
http://www.gmayor.com/installing_macro.htm

For help on assigning shortcuts, see:
http://word.mvps.org/FAQs/Customization/AsgnCmdOrMacroToHotkey.htm

NOTE: When checking which built-in command is run when pressing Shift+F8,
Word tells it is a command named "EndOfLineExtend". Therefore, if you install
the above macro and change its name to "EndOfLineExtend", the macro should
run instead of the built-in command. However, for some reason, I could not
make this work when testing.

--
Regards
Lene Fredborg
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word
 
G

Guest

Lene --

Thank you very much for this help! I just implemented this, and it looks
good! I'll work with it in the days ahead, and see if any additional
questions arise. Incidentally given the anticipated preferable behavior of
the macro, I assigned the macro to keysequence shift-end (overriding the
default EndOfLineExtend assignment). Thanks again!!

--Will
 
G

Guest

Lene --

The Macro is working great! --

Here is another related scenario: Also in outline view, my cursor is on the
2nd-to-last line of a paragraph, BUT is farther to the right than the end of
the last line of the paragraph. Here is the problem: If I press
shift-downarrow, the entire paragraph highlights, instead of just from the
initial cursor position to the end of the paragraph.

I could try and put together a macro -- but I'll bet this is trivial for you
if you haven't already done it (I suppose it would involve a test if the
cursor is farther right than the end of the last line of the paragraph, or
perhaps if the character under the cursor is a carriage return)

Thanks in advance!
--Will
 
G

Guest

I am glad the macro works. Actually, even it the macro ended up being very
simple, it took some experiments to get there. And no, I did not have any
macro that solved the Shift+down arrow problem in Outline view. I decided to
try making one - and it ended up being rather tricky because a lot of the
information you can retrieve about position etc. seems to be unreliable in
Outline view (as also stated in the article at
http://word.mvps.org/faqs/macrosvba/GetIndexNoOfPara.htm)

However, I think I succeeded in creating a macro that - at least in my tests
- works acceptable but not perfectly. Note the following: If you run the
macro repeatedly and if the selection expands from one paragraph to another
and if the original start of the selection was to the right of the paragraph
end, the end of the next selection will stop at the same horizontal position
as the paragraph end above, i.e. the selection in the last line will be
"shorter" than it should have been (I decided to accept this). Also note that
the macro may sometimes add two lines to the selection instead of one
(because the line count is not reliable either - Word seems to base the
calculation of lines on Print Layout view). But as opposed to using
Shift+Down Arrow, the macro will at least not just extend the selection to
entire paragraph(s).

The built-in command that is executed when pressing Shift+Down Arrow is
"LineDownExtend". Correspondingly, the commands executed when using the other
arrow keys are LineUpExtend, LineRightExtend and LineLeftExtend. The NOTE in
my previous post also applies here.

Here is the macro that attempts to make LineDownExtend work "normally", also
in Outline view (note that long lines in the macro may be broken):


Sub LineDownExtend_Special()

Dim nOldLastLine As Long
Dim nNewLastLine As Long
Dim nStartPos As Long

With Selection
'If in Outline view, compensate for "wrong" selection
If ActiveDocument.ActiveWindow.View.Type = wdMasterView And
ActiveDocument.Subdocuments.Count = 0 Then
'Outline view
'Find start position of selection
nStartPos = Selection.Start
'Find line number of last selected line
nOldLastLine =
..Characters.Last.Information(wdFirstCharacterLineNumber)
'Extend selection in the normal way
.MoveDown Unit:=wdLine, Count:=1, Extend:=wdExtend
'If start position has changed, reset to original position
If .Start <> nStartPos Then
.Start = nStartPos
End If
'If more than one line added to the selection, reset selection end
nNewLastLine =
..Characters.Last.Information(wdFirstCharacterLineNumber)
If nNewLastLine > nOldLastLine + 1 Then
.MoveEnd Unit:=wdLine, Count:=-(nNewLastLine - nOldLastLine)
+ 1
End If
Else
'If not Outline view - just move down
.MoveDown Unit:=wdLine, Count:=1, Extend:=wdExtend
End If
End With
End Sub

If you wish macros for the other Shift+Arrow key variants, it is up to you
to create them ;-)

--
Regards
Lene Fredborg
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word
 
G

Guest

Lene --

Another great help. Many thanks. Yes, this works much of the time --
enough of the time for my purposes, I think. In the interim I actually
approximated the first portion of what you wrote -- but didn't know how to
prevent the selection of the entire next paragraph -- thanks for that.

I note that having paragraphs collapsed in the outline view above the
selection of interest fouls things up, and the functionality reverts to
selecting entire paragraphs (probably due to the internal confusion of line
numbering, as you alluded).

Too bad that there isn't a cleaner, more consistent way of dealing w/
locating "lines" in outline view. I wouldn't be surprised if the challenges
there have something to do with why MS made the default behavior as they did.

In any case, this is helpful, and I appreciate it very much!

Also, should I need other shift-arrow functionality, I will definitely take
initiative before posting =]. Your guidance has been very helpful.
 

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