I’m trying to create a simple script that will let me choose a folder of images and then create a quick powerpoint slide show of them:
set this_folder to (choose folder with prompt "Pick the folder containing the images to process:")
tell application "System Events"
set these_files to every file of folder this_folder whose name does not start with "." and (file type is "TIFF" or file type is "JPEG" or name extension is "tiff" or name extension is "tif" or name extension is "jpeg" or name extension is "jpg")
end tell
tell application "Microsoft PowerPoint"
activate
set this_presentation to make new presentation
repeat with i from 1 to the count of these_files
set this_file to (item i of these_files as string)
set this_slide to make new slide at the end of the active presentation with properties {layout:slide layout large object}
-- copy the position and dimensions of the placeholder box
tell shape 1 of this_slide
copy {top, left position, width, height} to {shape_top, shape_left, shape_width, shape_height}
delete
end tell
-- make a new picture box
-- display dialog (this_file as string)
set picture_shape to make new picture at this_slide with properties {top:shape_top, left position:shape_left, lock aspect ratio:true, file name:this_file}
-- scale the picture to a smaller size
scale height picture_shape factor 0.25 scale scale from top left with relative to original size
scale width picture_shape factor 0.25 scale scale from top left with relative to original size
-- get the dimensions of the picture
tell picture_shape
copy {width, height} to {picture_width, picture_height}
end tell
-- adjust the picture to fit
if the picture_height is greater than the picture_width then
set the height of the picture_shape to the shape_height
else
set the width of the picture_shape to the shape_width
end if
-- show the slide
set the slide of the view of document window 1 to this_slide
end repeat
end tell
The problem is when it actualy gets to the make new picture line it fails with an error from Powerpoint saying :
“Microsoft PowerPoint got an error: Can’t make a picture.”
Any clues?
Thanks for the help
John Scherer