0

I'm trying to access Keynote shapes and their properties (in this case the text) using JavaScript for automation using this:

var k = Application("Keynote")
k.includeStandardAdditions = true

var p = k.open("/Users/simonecesano/Desktop/status_update-20220909.key")

p.slides().forEach((s, i) => {
    s.textItems().forEach((t, i) => {
    try {
        s.textItems(i).forEach((u, j) => {
        console.log(
            j,
            Automation.getDisplayString(u.objectText.paragraphs.at(0)),
            // this throws can't convert types
            u.objectText.paragraphs.at(0) 
        )
        })
    } catch(e) { console.log(e) }
    })
})

It works kind of fine until I try to actually access the text of the paragraphs, where I get

Error: Can't convert types.

Why is that? How can I fix it?

(applescript tag is kind of borderline, I know, bu there is no Javascript-for-automation)

simone
  • 4,667
  • 4
  • 25
  • 47

0 Answers0