ドキュメントファイルの情報を読み込みたい。
Ex. doc.odt file
David
12.13
OO
以下の情報を編集したい
David --> DAVID
12.13 --> 12.14
OO --> OpenO
リスト編集情報をテキストファイルにエクスポート
Ex. changes.txt file
DAVID
12.14
OpenO
私の問題:段落に他の文字がある場合、編集情報をテキストファイルにエクスポートしません。
私のコード1
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
私のコード2
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