I want to take a word document with pictures and copy each one, save it in photoshop, or image events, as a .tiff.
I have MS Word 2004, Photoshop CS2 running on 10.4.8.
Can anyone show me a snippet that would do this, please?
Thank you very much,
PhotoScripter
PhotoScripter:
The only way I have figured out how to do this is to download the Scripting Addition “GraphicsImporter” here, installing it according to the enclosed instructions, and using this script:
tell application "Microsoft Word"
select inline picture 1 of active document
copy object selection
my writeImageFile()
end tell
on writeImageFile()
set theFile to (((path to desktop) as string) & "newImage.tif") as file specification
set theImage to the clipboard as picture
set thePict to giconvert (theImage) type "TIFF" image theFile
end writeImageFile
This is based on Fenton’s comments in this thread.
It is too late for me to figure out how to go further and save all the images in a document, but I don’t think it would be difficult to select them all, and use a repeat loop to save them one at a time. If I can scrounge up some time in the next few days, I may give it a try and post my findings.
Good luck,
Ciao,
starting from Craig’s example I’ve tried to get the whole job done by the Finder and this works for me (not very fast however) without using 3rd party scripting additions:
set saveFolder to (choose folder)
tell application "Microsoft Word"
set myPics to inline pictures of document 1
repeat with i from 1 to count of myPics
select item i of myPics
copy object selection
my writeImageFile(saveFolder, i)
end repeat
end tell
on writeImageFile(saveFolder, i)
tell application "Finder"
set theFileName to ("image" & i & ".jpg")
set theImage to the clipboard as picture
set newFile to (make new file at saveFolder with properties {name:theFileName}) as alias
open for access newFile with write permission
set eof newFile to 512
write theImage to newFile as picture starting at 513
close access newFile
end tell
end writeImageFile
Good scripting
Farid