Unable to add a slide to presentation using Apple Script

Hi everyone,

I am trying to create a presentation and add a slide to it using Apple Script - I have taken help from ChatGPT of course but I keep getting stuck at something or the other and I don't understand what I can do (I am a complete newbie to this so please pardon me!)

I have used the below code:

tell application "Microsoft PowerPoint"
    activate
    set newPresentation to make new presentation
    set newSlide to make new slide at end of slides of newPresentation
end tell

But this throws up the error:

error "Microsoft PowerPoint got an error: Can’t make or move that element into that container." number -10024

which I mean to understand that I can't tell the application to create a slide? In that case I have tried using 'tell' for the presentation as well with the following code:

tell application "Microsoft PowerPoint"
    activate
    set newPresentation to make new presentation
    tell newPresentation
        set slideCount to count of slides
        set newSlide to make new slide with properties {position:slideCount + 1}
    end tell
end tell

But this throws up the error:

error "Microsoft PowerPoint got an error: Can’t make {position:1} into type properties of slide." number -1700 from {position:1}

which somehow simply seems to tell me that I can't add the position of the slide into properties? Then I tried the following code:

tell application "Microsoft PowerPoint"
	activate
	set newPresentation to make new presentation
	set slideCount to count of slides of newPresentation
	tell newPresentation
		set newSlide to make new slide at slide (slideCount + 1) of slides of newPresentation
	end tell
end tell

But again I have the following error:

error "Microsoft PowerPoint got an error: Can’t get slide 1 of every slide of presentation "Presentation1"." number -1728 from slide 1 of every slide of presentation "Presentation1"

which seems to tell me I can't create slide 1 using this method?

And now I am confused as to what I can do to create a new slide.

Any help is sincerely appreciated!

Unable to add a slide to presentation using Apple Script
 
 
Q