I want to add a line to a macro so it goes to the next slide in a presentation.
I found - oController.gotoBookmark(“Slide name here”) - and tried to use it as - oController.gotoBookmark(“slide2”) - but i get a runtime error, variable not set. I guess I have to declare something but have no idea what or where.
hello @wdr,
poor mans help, google around and ‘trial and error’ …
after some of above the following code worked for me:
Sub impress_jump_target
Doc = ThisComponent
Presentation = Doc.Presentation
Presentation.Start()
Controller = Presentation.Controller
Controller.GotoBookmark("Slide 3")
end sub 'impress_jump_target
my breakthrough from different error messages came with:
AOO Forum: Impress running macro
feel free to ask if you need the complete file,
be aware LO macros sometimes are … a bumpy road,
be aware that above macro is neither ‘nice’ nor ‘standard’ as it doesn’t follow marking variable types by prefixing them with ‘o’, ‘b’, ‘n’ …,
may be your only fault was “Slide 3” vs. “slide2”,
just try and report …
if this answer helped you you can encourage my motivation for further contributions by flagging it as ‘correct answer’ and / or upvoting with the symbols on the left sidebar in this box,
regards,
b.
Thank You for the trouble and the help. Still there is something not working i am still getting the error message with the line Controller.GotoBookmark (“Slide 2”). I tried several names for the slide. The runtime error is “variable not set”. I’ll keep looking thanks, anyhow for the time. I’ll keep the post open for a fewe days maybe someone else has an idea .
Thanks for the support. I found a working solution. I don
t look any further to go to the next question automatically. They can try all the answers and at the end they will see how many times they tried.
I post the code below if any one is looking for something similar.
Global numberCorrect as integer
Global numberwrong as integer
Sub start
numberCorrect = 0
numberWrong = 0
End Sub
Sub Correct
numberCorrect = numberCorrect + 1
MsgBox "Well Done , you got " & numberCorrect & " correct anwers" & "." , , "Quiz"
End Sub
Sub Wrong
MsgBox "Sorry , that is incorrect, you can try again or move to the next question" , , "Quiz"
numberWrong = numberWrong + 1
End Sub
Sub result
MsgBox " you got " & numberCorrect & " out of " & numberCorrect + numberWrong & " answers correct " & "." , , "Quiz results"
End Sub
The error message indicates that oController
is null. This is how to set the variable correctly.
oPresentation = ThisComponent
oPresentation.Start()
oController = oPresentation.Controller
https://wiki.openoffice.org/wiki/Documentation/DevGuide/Working_with_Presentations