TextStatus object and selection

Build 1501 on 14/Nov/2017  This topic last edited on: 9/May/2012, at 13:02

In the case of a TextStatus object obtained from a text using the GetTextStatus function, each attribute property has a value either if the text has no selection, or if the correponding attribute has the same value for the whole selection, e.g.:

Dim objTS = Text.GetTextStatus

If Not objTS.HasFontCode Then

 MsgBox ("The selected text uses multiple fonts")

Else

If Text.TestTextSelection Then

   MsgBox ("The selected text uses the font " & objTS.FontCode)

Else

   MsgBox ("The current font at the cursor position is " & objTS.FontCode)

End If

End If

As you can see from above, if a multiple selection would return different values, the property is not set and it will cause an error, either in reading or in writing. Therefore, before each operation on a property, it is required that you use the appropriate "Has" function, to check if the property is correct.