In a software that I am developing I have to allow a user to pick a document which is in .RTF format and load it in TX Text Control. Then extract data from each row (column 2) and save it to another TX Text Control.
The document in question contains one Table in which all the text is contained.
Here is the code that I am using to extract text from second Column of each Row:
With TXTextControl1
.SetFocus
.ResetContents
.LoadSaveAttribute(txLoadImages) = True
.Load fn, 0, 5
DoEvents
I = .TableNext(I, CurTableID)
If CurTableID = 0 Then
MsgBox "Document Format is NOT Proper", vbInformation, App.Title
Screen.MousePointer = vbNormal
Exit Sub
End If
For J = 1 To .TableRows(CurTableID) - 1 'Step 7 'Loop through all Rows
.SelStart = .TableCellStart(CurTableID, J, 2) - 1
.SelLength = .TableCellLength(CurTableID, J, 2)
Debug.Print "Row: " & J, .TableColAtInputPos
List1.AddItem "Row: " & J & " Col Cnt: " & .TableColAtInputPos & IIf(.TableColAtInputPos = 0, " <= Problem Here", "")
TXTextControl2.SelText = J & vbCrLf
TXTextControl2.RTFSelText = .RTFSelText
TXTextControl2.SelText = vbCrLf
DoEvents
Next J
End With
But this code seems to show inconsistent behavior of TX Text Control in selecting Cell contents. At times it is selecting the whole row instead of just the cell contents.
To demonstrate this inconsistent I have created a demo which can be downloaded from here.
Any ideas how to overcome this bug?
TIA
Yogi Yang