AuthenticRange.LastTextPosition
Property: LastTextPosition as Long
Description
Set or get the rightmost text position index of the range object. This index is always greater or equal to FirstTextPosition. Indexing starts with 0 at the document beginning, and increments with every different position that the text cursor can occupy. Incrementing the test position by 1, has the same effect as the cursor-right key. Decreasing the test position by 1 has the same effect as the cursor-left key.
If you set LastTextPosition to a value less then the current FirstTextPosition, FirstTextPosition gets set to the new LastTextPosition.
HINT: Use text cursor positions with care, since this is a costly operation compared to XMLData based cursor positioning.
Errors
2001 | The authentic range object, or its related view object is not valid. |
2005 | Invalid address for the return parameter was specified. |
2006 | A text position outside the document was specified. |
Examples
' ---------------------------------------
' Scripting environment - VBScript
' ---------------------------------------
Dim objAuthenticView
' we assume that the active document is open in authentic view mode
Set objAuthenticView = Application.ActiveDocument.AuthenticView
nDocStartPosition = objAuthenticView.DocumentBegin.FirstTextPosition
nDocEndPosition = objAuthenticView.DocumentEnd.FirstTextPosition
' let's create a range that selects the whole document
' in an inefficient way
Dim objRange
' we need to get a (any) range object first
Set objRange = objAuthenticView.DocumentBegin
objRange.FirstTextPosition = nDocStartPosition
objRange.LastTextPosition = nDocEndPosition
' let's check if we got it right
If objRange.isEqual(objAuthenticView.WholeDocument) Then
MsgBox "Test using direct text cursor positioning was ok"
Else
MsgBox "Oops!"
End If