As I continue to develop a larger script (which is working but for this), I can't figure out how to insert a file into a Word document using Applescript. I can insert a picture, but if the file is a Word doc, an Excel spreadsheet, a video file, etc., I can't see in the dictionary where the commands are that would handle that. This example almost works:
on AddAttachmentFileToWordDoc(FilePath, Extension)
set GraphicFiles to {"PDF", "jpg", "giff", "TIFF", "gif", "png", "PPM", "PGM", "PNM"}
set VideoFiles to {"mov", "wmv", "amv", "mp4", "m4p", "mpg", "mpeg", "m4v"}
tell application "Microsoft Word"
activate
tell active document
set ContTemp to content of text object
set StartRange to (count of ContTemp) - 1
set endrange to StartRange
set theRange to create range start StartRange end endrange
tell theRange
if GraphicFiles contains Extension then
--this works well
make new inline picture at end with properties {file name:FilePath as text, save with document:true}
else if VideoFiles contains Extension then
--this obviously doesn't work, but I would guess that something close to it should.
make new video at end with properties {file name:FilePath as text, save with document:true}
else -- everything else, Word docs, excel, etc.
--make new what?? There is no option for new inline file . . .
end if
end tell
end tell
end tell
end AddAttachmentFileToWordDoc
As you can see I have only succeeded with the graphic files. Any ideas what the syntax for the other file types should be? Thanks a million!