I set up a simple search macro. It works as long as I set the cursor at the beginning of the document and search forward.
But if I set the cursor at document end and search backward, which is what I need to do, the search finds nothing.
In the following code, toggling the two marked sections breaks the search.
sub testtt
Dim vDescriptor, vFound, oCursor, i, j
vDescriptor = ThisComponent.createSearchDescriptor()
'rem goto doc end: THIS IS THE PART THAT BREAKS IT
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dispatcher.executeDispatch(document, ".uno:GoToEndOfDoc", "", 0, Array())
' Set the text for which to search and other
With vDescriptor
.SearchString = "o"
.SearchBackwards = True ' THIS IS THE CORRESPONDING PART THAT BREAKS IT
End With
vFound = ThisComponent.findFirst(vDescriptor)
if isnull(vFound) then
msgbox "not found", 64, "title"
else
oCursor = ThisComponent.CurrentController.ViewCursor
oCursor.gotoRange(vFound, false)
end if
end sub