Impress does not run macro in presentation mode

Hello, in Presenter 24.2.2 I have created a document with 6 cards, I have added the ‘New card’ button that randomly shows one of six cards, a second ‘HOME’ button takes me to the start of the presentation from any card. If I apply ‘F5’ the presentation starts, but the buttons on each card do not work according to the macro, if I exit presentation mode the buttons work very well. I request help to find a solution, below is the code:

REM ***** BASIC *****

Sub ElegirNuevaTarjeta
Dim oDoc As Object
Dim oController As Object
Dim oDrawPages As Object
Dim nRandomPage As Integer

oDoc = ThisComponent
oController = oDoc.getCurrentController()
oDrawPages = oDoc.getDrawPages()

' Generar un número aleatorio entre 2 y 7
Randomize
nRandomPage = Int((7 - 2 + 1) * Rnd + 2)

' Cambiar a la lámina seleccionada de forma aleatoria
oController.setCurrentPage(oDrawPages.getByIndex(nRandomPage - 1))

End Sub

Sub IrALaminaPrincipal
Dim oDoc As Object
Dim oController As Object
Dim oDrawPages As Object

oDoc = ThisComponent
oController = oDoc.getCurrentController()
oDrawPages = oDoc.getDrawPages()

' Cambiar a la primera lámina (lámina del título principal)
oController.setCurrentPage(oDrawPages.getByIndex(0))

End Sub


At the suggestion of someone on the forum, I share the Impress document with the macro in question.
Test_oscar.odp (14.5 KB)

maybe if you attached a sample document, the interest to provide help would raise up – cause let me confess : reading some code in abstracto is not the most appealing :wink:

That’s it, I’ll upload it right away.

Thanks to the help of the forum I have reached a complete solution to my problem, I leave the .odp document for the help of other members with problems executing macros in presentation mode, I have used LibreOffice Impress 24.2.2
random_6card.odp (16.3 KB)

1 Like

Check the answer by @JohnSUN
in the linked thread. Presentation mode seems to have its own controler:

Thank you very much for your recommendation, I will check the link.
I just uploaded the document with the macro that doesn’t work.