Altova StyleVision 2024 Professional Edition

Property: FirstTextPosition as Long



Set or get the left-most text position index of the range object. This index is always less or equal to LastTextPosition. Indexing starts with 0 at 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. Decrementing the test position by 1 has the same effect as the cursor-left key.


If you set FirstTextPosition to a value greater than the current LastTextPosition, LastTextPosition gets set to the new FirstTextPosition.


HINT: Use text cursor positions with care, since this is a costly operation compared to XMLData based cursor positioning.




The authentic range object, or its related view object is not valid.


Invalid address for the return parameter was specified.


A text position outside the document was specified.



' ---------------------------------------

' 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"


 MsgBox "Ooops!"

End If

© 2018-2024 Altova GmbH