问题
I have a libreoffice macro to go to a certain bookmark ("qui")
sub vai_qui
ViewCursor = ThisComponent.CurrentController.getviewCursor()
Bookmark = ThisComponent.Bookmarks.getByName("qui").Anchor
ViewCursor.gotorange(Bookmark, False)
end sub
The problems are two:
- this is a libreoffice macro, and so it runs also with Calc and Base, and I'd like to avoid error messages in Calc and Base;
- With this macro the cursor go to the bookmark, but the focus of Writer is not on the cursor: I prefer to avoid this situation and have focus on cursor.
Thank you
回答1:
As you have been told on LibreOffice forum***:
- avoid calling the macro, if you don't have a Writer document
check for the document type
If NOT ThisComponent.supportsService("com.sun.star.text.TextDocument" ) Then Exit Sub End If
check for bookmarks existence
oBookmarks = ThisComponent.getBookmarks() If NOT oBookmarks.hasByName("qui") Then
*** Cross-posting a question without any reference to other forums you asked for help is offending to the volunteers who spend their free time to help.
来源:https://stackoverflow.com/questions/46204381/fine-tuning-a-goto-bookmark-libreoffice-macro