AppleScript export PowerPoint slides to PNG - not working


that code is correct but nothing happens: no images exported !

can you help please ?

tell application “Microsoft PowerPoint”
open “/Users/pierreduran/Documents/Pres/pres.pptx”
set theOutputPath to ((path to desktop) as text) & “pnghole:”
–display dialog theOutputPath
tell active presentation
save in theOutputPath as save as PNG
end tell
end tell

There are tons of Applescript commands that are broken in Office apps.
And it’s been going on for a long, long time.

Since it is still possible to export a presentation to pdf, we can use it to get every slide as jpg:

use framework "Foundation"
use framework "AppKit"
use scripting additions

set pdfPath to "~/Library/Group Containers/UBF8T346G9.Office/TemporaryItems/"
set pdfPath to (current application's NSString's stringWithString:pdfPath)'s stringByExpandingTildeInPath()'s stringByAppendingString:"/exportPDF.pdf"

tell application id "PPT3"
	set docPath to full name of active presentation
	save active presentation in (pdfPath as «class furl») as save as PDF
end tell

set sourceURL to current application's NSURL's fileURLWithPath:pdfPath
set destURL to current application's NSURL's fileURLWithPath:docPath
set destName to destURL's URLByDeletingPathExtension()'s lastPathComponent()
set destFolder to destURL's URLByDeletingLastPathComponent()'s URLByAppendingPathComponent:destName
set theFileManager to current application's NSFileManager's |defaultManager|()
theFileManager's createDirectoryAtURL:destFolder withIntermediateDirectories:true attributes:(missing value) |error|:(missing value)

set theDoc to current application's PDFDocument's alloc()'s initWithURL:sourceURL
set pageCount to (theDoc's pageCount())
repeat with iPage from 1 to pageCount
	set thePage to (theDoc's pageAtIndex:(iPage - 1))
	set theImg to (current application's NSImage's alloc()'s initWithData:(thePage's dataRepresentation()))
	set theTiff to theImg's TIFFRepresentation()
	set theRep to (current application's NSBitmapImageRep's imageRepWithData:theTiff)
	set theJpeg to (theRep's representationUsingType:(current application's NSJPEGFileType) |properties|:{NSImageCompressionFactor:(1), NSImageProgressive:false})
	set destURL to (destFolder's URLByAppendingPathComponent:("" & destName & "•" & (text -3 thru -1 of ("000" & iPage)) & ".jpg"))
	set theResult to (theJpeg's writeToURL:destURL atomically:true)
end repeat

In the line set pdfPath to "~/Library/Group Containers/UBF8T346G9.Office/TemporaryItems/" the UBF8T346G9 part may not be the same on your system.
Use the Finder to open the Group Containers folder and get the actual identifier.