Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub SimpleSearchExample
- parseWordsFromCurrentDoc()
- End Sub
- Public Function parseWordsFromCurrentDoc()
- Dim vDescriptor, vFound
- vDescriptor = ThisComponent.createSearchDescriptor()
- With vDescriptor
- .SearchString = "\w+"
- .SearchRegularExpression = true
- End With
- vFound = ThisComponent.findFirst(vDescriptor)
- proccessVFound(vFound)
- Do While Not IsNull(vFound)
- vFound = ThisComponent.findNext(vFound.End, vDescriptor)
- proccessVFound(vFound)
- Loop
- End Function
- Public Function wordCount(wordToSearch) As Integer
- Dim vDescriptor, vFound
- vDescriptor = ThisComponent.createSearchDescriptor()
- Dim count As Integer
- With vDescriptor
- .SearchString = wordToSearch
- .SearchWords = true
- .SearchCaseSensitive = true
- End With
- vFound = ThisComponent.findFirst(vDescriptor)
- count = 0
- Do While Not IsNull(vFound)
- count = count + 1
- vFound = ThisComponent.findNext(vFound.End, vDescriptor)
- Loop
- wordCount = count
- End Function
- Public Function proccessVFound(vFound)
- Dim count As Integer
- Dim word As String
- If Not IsNull(vFound) Then
- word = vFound.String
- count = wordCount(word)
- exportResultToCalc(word,count)
- End If
- End Function
- 'export to OpenOffice.Calc
- Public Function exportResultToCalc(word,count)
- 'Fake!!!!!!!!!!!!
- 'But work :)
- MsgBox "word="+word+"; count="+count
- 'to be continued....
- End Function
Add Comment
Please, Sign In to add comment