I would like read information of document file.
Ex. doc.odt file
David
12.13
OO
I want to edit information below
David --> DAVID
12.13 --> 12.14
OO --> OpenO
and export list edit information to text file
Ex. changes.txt file
DAVID
12.14
OpenO
My problem: if have any other character in paragraph, it will not export edit information to text file.
My code1
Dim filesize As Integer
Dim FlName As String
Dim Descriptor As Object
Dim Found As Object
Dim FoundAll As Object
Dim i
Dim Doc As Object
Dim Enum As Object
Dim TextElement As Object
Doc = ThisComponent
Enum = Doc.Text.createEnumeration
FlName = "C:\changes.txt"
Descriptor = ThisComponent.createSearchDescriptor()
filesize = FreeFile()
FoundAll = ThisComponent.findAll(Descriptor)
Open FlName For Output As #filesize
While Enum.hasMoreElements
TextElement = Enum.nextElement
If TextElement.supportsService("com.sun.star.text.Paragraph") Then
TextElement.String = Replace(TextElement.String, "David", "DAVID")
If TextElement.String = "DAVID" Then
Print #filesize, "DAVID"
End If
TextElement.String = Replace(TextElement.String, "12.13", "12.14")
If TextElement.String = "12.14" Then
Print #filesize, "12.14"
End If
TextElement.String = Replace(TextElement.String, "OO", "OpenO")
If TextElement.String = "OpenO" Then
Print #filesize, "OpenO"
End If
End If
Wend
Close #filesize
My code2
Dim C As Object
Dim R As Object
Dim M As Object
Dim Found As Object
Dim FoundAll As Object
Dim i
C = ThisComponent.createSearchDescriptor()
R = ThisComponent.createSearchDescriptor()
M = ThisComponent.createSearchDescriptor()
C.SearchString = ("David")
R.SearchString = "12.13"
M.SearchString = "OO"
FoundAll = ThisComponent.findAll(Descriptor)
For i = 0 to FoundAll.getCount()-1
Found = FoundAll.getByIndex(i)
If Descriptor.SearchString = "David" Then
Found.setString("DAVID")
End If
If Descriptor.SearchString = "12.13" Then
Found.setString("12.14")
End If
If Descriptor.SearchString = "OO" Then
Found.setString("OpenO")
End If
Next