Microsoft PowerPoint

Insert image into slide

This inserts a picture into the master slide for all of the slides to use as a background. The key to inserting a picture class is that there needs to be a location that isn’t end; the file name property has to be an actual object in the presentation, and can’t only be set upon creation. Beyond that file name is “get” only so make that file path count. (I’m amazed how much mis-information there is out there about this and how hard it was to find official information from Microsoft (I didn’t find any). But, this absolutely works in v2011.)

set theImage to "Macintosh HD:Users:username:path:to:image.ext”
 tell application "Microsoft PowerPoint"
 set slideMaster to slide master of presentation 1
 set imageFrame to make new picture at slideMaster with properties {top:0, left position:0, width:width of slideMaster, height:height of slideMaster, lock aspect ratio:true, file name:theImage}
 end tell

Extract Text to Word

Any get content of text frame command has a 256 character limit (!) that causes a hard crash (!!). We have to use the copy/paste commands to workaround this. (!!!)

global thisSlide
 global thisShape
tell application "Microsoft PowerPoint"
 set theDocumentWindow to document window 1
 set thePresentation to presentation of theDocumentWindow
 set thePresentationName to name of thePresentation
tell application "Microsoft Word"
 make new document
 end tell
tell thePresentation
 set SlideCount to (get count of slides)
 repeat with thisSlide from 1 to SlideCount
 set theSlide to slide thisSlide
 tell theSlide
 set ShapeCount to (get count of shapes)
 repeat with thisShape from 1 to ShapeCount
 set theShape to shape thisShape
 set theTextFrame to text frame of theShape
 set theTextRange to text range of theTextFrame
try --because sometimes copy doesn't have a value from theTextRange (i.e. theTextRange is empty)
 copy text range theTextRange
tell application "Microsoft Word"
 set range2 to text object of active document
 set range2 to collapse range range2 direction collapse end
paste object range2
 insert paragraph at range2
 end tell
 end try
end repeat --Shapes
 end tell --theSlide
 end repeat --Slides
 end tell --thePresentation
tell application "Microsoft Word"
 set theDesktopFolder to path to desktop as Unicode text
 set theFileName to (thePresentationName as string) & ".rtf"
 save as document 1 file name (theDesktopFolder & theFileName) file format format rtf
 close active document saving no
 end tell
 end tell --Powerpoint