on run argv if (count of argv) > 0 then set cropShape to item 1 of argv else error "Crop shape is not provided" end if tell application "System Events" tell application "Microsoft PowerPoint" if (count of slide show windows) > 0 then -- Run when in presentation mode error "PowerPoint is in presentation mode. Cannot perform operation." number 60002 else -- Get selected shapes set theShapeRange to shape range of selection of active window set shapeCount to (count of shapes of theShapeRange) if shapeCount = 0 then error "No shape is selected" else if shapeCount > 1 then error "Multiple shapes are selected" end if -- Get the shape type set selectedShape to shape 1 of theShapeRange set shapeType to shape type of selectedShape set shapeType to shapeType as string if shapeType is "shape type picture" or shapeType is "shape type auto" then set auto shape type of selectedShape to cropShape my clickCrop() else error shapeType & " is not an image. Cannot perform operation." number -1 end if end if end tell end tell end run to clickCrop() tell application "System Events" tell process "Microsoft PowerPoint" click menu item 19 of menu 7 of menu bar 1 end tell end tell end clickCrop