How can I get the slide number of the current slide in Keynote?

I need to get the slide number of the slide currently selected in Keynote, so I can do further processing? Do I need to use AppleScript? If so, does anyone have a snippet that will work? Thanks.

Okay, I got this far with AppleScript, but I can’t figure out how to convert (or extract) the slide number from the selectedSlide variable. I thought it would be as simple as converting this to a string, but I haven’t had any luck with that.

Assuming you want to save the currently selected slide number to a KM variable (please note this is an action, not a macro, and will automatically be imported into the macro currently being edited when opened):

Execute an AppleScript.kmactions (812 Bytes)

AppleScript:

tell application "Keynote"
	set selectedSlide to slide number of current slide of front document
end tell

return selectedSlide
1 Like

Perfect! I literally just stumbled across a similar solution from some code I extracted elsewhere. I appreciate it!

1 Like

Michael,

This is a recent conversation that I had with @gglick.

Kcwhat: @gglick, what do you do for a living?
@gglick: Post solutions.
Kcwhat: Nuff said...

1 Like

Hi there! I just found this thread : )

How can I use this script to start another macro, when lets say slide 8 starts running?
Or can I even have a specific name on a slide, that shows up as a variable :grinning: that trigs a macro... A specific name would help a lot if I change the order of the slides, so that lets say the slide with the name of "saying" will trigger a macro instead of "slide 5" that might bi another slide that I want to have as a trigger...