I need a macro that moves cursor to chosen section or paragraph in Writer. I have some macros that show/hide sections and I’d like to instant set the view to the uncovered text. Could you help with such a macro? or some another solution?
How “chosen”?
In what way did you “cover” / “uncover” text?
In what way do you have access to the sections you are talking of?
The visual cursor (ViewCursor) you can only set to one TextRange at a time via the API.
mySection
being the section object, you can set the ViewCursor
spanning its complete range by
thisComponent.CurrentController.select(mySection.Anchor)
thisComponent.CurrentController.select(mySection.Anchor)
This is almost right, but just need to only put cursor in the first (or last) paragraph of “mySection”, without selecting the whole. Is it possible? Sorry, but i don’t know the LO Basic “very well” (neither do English :P).
Use (e.g.)
ThisComponent.CurrentController.select(mySection.Anchor.Start)
It’s not the primitive Basic coming with LibreOffice, but the elaborate API you need for the task.
If you think to need macro programming for LibreOffice, you should probably start wit the famous texts by Andrew Pitonyak. They are named after “Basic” but lots of the content are actually about using the API - and the examples are in Basic.
Thank you for your book. It may be very helpful for me as a newbie for LibreOffice macros.