View Full Version : Solved: EndKey vs EndOf
Adamski
06-04-2009, 05:44 AM
Just a quickie...
Whats the difference between the Selection Methods, EndKey and EndOf?
Also, HomeKey and StartOf?
I notice the Range object dosen't have EndKey and HomeKey.
Thanks
fumei
06-04-2009, 08:57 AM
Have you tried comparing them in Help?
In many ways, yes, they are very similar, but there are some subtle differences between EndKey and EndOf.
No, Range does not have EndKey. EndKey is essentially pressing....the End key. A range is a numeric entity/object (it is NOT within the GUI, it is "internal" and wholly within VBA) and therefore pressing the End key is irrelevant...therefore, there is no EndKey method for a Range.
EndKey: "Moves or extends the selection to the end of the specified unit. "
EndOf: "Moves or extends the ending character position of a range or selection to the end of the nearest specified text unit."
Note that both methods return a value, the number of characters moved.
It may also be helpful (again looking in Help and actually reading and comparing) to see the Units that used by each method.
EndKey wdUnits
wdStory
wdColumn
wdLine
wdRow
EndOf wdUnits
wdCharacter
wdWord
wdSentence
wdParagraph
wdSection
wdStory
wdCell
wdColumn
wdRow
wdTable
Note, in particular that EndKey does have wdLine as a parameter - and in fact THAT is the default - by EndOf does not have wdLine as an available parameter.
Adamski
06-05-2009, 03:20 AM
Thanks fumei,
EndKey: "Moves or extends the selection to the end of the specified unit. "
EndOf: "Moves or extends the ending character position of a range or selection to the end of the nearest specified text unit."
I did look it up in help and got the definitions quoted, but it seems (to me) like two ways of saying the same thing - achieving the same result.
Only the wdUnits are different so can I just use EndOf for everything except wdLine, and only use that with the selection object?
Basically is this statement correct?
"The only additional functionality of EndKey over EndOf is to move/extend a selection to the end of the line."
Maybe I'm missing something but EndKey seems (fairly) redundant.
Thanks again.
fumei
06-05-2009, 10:48 AM
Well, in a way, yes it seems a redunancy, however, one applies to ONLY the Selection, the other applies to either Selection, or Range.
In particular the parameter wdStory is, yes, rather redundant. Note however, that EndOf moves or extends to the nearest specified text unit.
But...overall, yes, I agree, for the most part one may as well use EndOf for most purposes. About the only time I use EndKey is to move the Selection to the end (or beginning) of a document. And even then, I do not do that very often as I try to avoid using Selection at all.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.