This is off the top of my head because I'm a bit busy with other things
The end of the document is uniquely identified by being the end of the Range which is the document. So end of document is ..
Selection.Document.range.end
And the end of the Selection is simply ..
Selection.End
They are both numbers - if they are the same you're at the end of the document.
Lines are slightly different - there is no Line Object but you can identify the end of the current line using the built-in bookmark ..
selection.Bookmarks("\Line").end
If the selection is collapsed (i.e. just an insertion point) all is well and you can compare it to the selection.end
BUT .. if the selection spreads over multiple lines the "\line bokmark returns the first line of the selection so some extra messing around would be needed in that case