I am pretty new to LibreOffice scripting, but I have some experience in VBA.
What I want to do is to add a shape to a slide in impress to use it as “button” to run a macro on click.
I get the shape added without much hassle, but I cannot get a click handler or event listener or whatever onto it via Basic scripting.
I can assign the handler with right clicking it, choosing “interactions” and run macro from the GUI but I need to replicate the same functionality programmatically.
Maybe someone has an idea or even an example for me?
Thank you
P.S. I searched a lot before asking here and there are some solutions around, that don’t seem to work for impress though.
sub setMacroInteraction
with ThisComponent.DrawPages.getByIndex(0).getByIndex(0) ' whatever shape
.onClick = com.sun.star.presentation.ClickAction.MACRO
.bookmark = "vnd.sun.star.script:Standard.Test.myHandler?language=Basic&location=application"
end with
end sub
sub myHandler
msgbox "... choosing “interactions” and run macro from the GUI"
end sub
Hello and thank you for your swift answer. I will try that later.
I found some posts mainly on this website.
Also another one I cannot find anymore with three ways to add events to things, that all didn’t work.
Inspectors don’t show this property (Or I am kind of blind…) and only show methods of add and remove EventListener for the shape, that lead nowhere. I had a look at the dev console But didn’t find the onClick or Bookmark properties.
I’ll gladly write up a short tutorial or sample and add it to the docs if you can point me to the place where it would be beneficial to add. But maybe it’s enough to have this post as further reference.
I really couldn’t find any information on the web how to set or get this property. Also it wasn’t obvious to me that I had to set the bookmark and that that influences the onClick action.
Again, thanks a lot and sorry if I have annoyed you with this simple question.
As I said, I am just starting with Libre Office scripting. When I get the hang of it, maybe I can also help others with questions here in the future.
Hope this will help others. I have a lot of other questions, but this time I will try to solve them myself.
Just not very encouraging if you have to search api documentation for a day to do the stuff that is pretty easy in VBA.