Mass import of images

J

Jeff Vandehey

Hi gang, I have about 30 photos I would like to import into PowerPoint. I
need each figure on an individual slide. Is there an automated way to do
this? Is there a script that exists?

Thanks
 
M

markrjl

I forget where on the notice board I found this


set this_folder to (choose folder with prompt "Pick the folder
containing the images to process:") as string
tell application "System Events"
set these_files to path of 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)
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
 
G

GeeMan

Can't get this AppleScript to work. I'm not proficient enough to
debug. Can anyone help?
 
P

Paul Berkowitz

Can't get this AppleScript to work. I'm not proficient enough to
debug. Can anyone help?

Which applescript? You mean the one markjri sent? (I had to to turn off
"Unread Messages Only" to try to guess what in the world you were talking
about.)

That would probably be because markjri pasted the script into a plain text
email message. That meant that all the long lines got hard-wrapped to new
lines, with carriage returns in the middle of lines. You don't mean that it
"doesn't run", you mean it "doesn't compile". It's the carriage returns
preventing the script from compiling. Yes, you would have to know a bit
about about AppleScript to figure out where to remove the extra CRs.

Fortunately, this newsgroup does accept HTML. And sending AppleScript or
other code is one situation where it's justified to send HTML messages here.
Here's the script fixed up and compiled. It seems to accept only TIFF and
JPEG files. It could be extended to other kinds of images that PowerPoint
accepts.


set this_folder to (choose folder with prompt "Pick the folder containing
the images to process:") as string
tell application "System Events"
set these_files to path of 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)
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

--
Paul Berkowitz
MVP MacOffice
Entourage FAQ Page: <http://www.entourage.mvps.org/faq/index.html>
AppleScripts for Entourage: <http://macscripter.net/scriptbuilders/>

Please "Reply To Newsgroup" to reply to this message. Emails will be
ignored.

PLEASE always state which version of Microsoft Office you are using -
**2004**, X or 2001. It's often impossible to answer your questions
otherwise.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top