Applescript to add images to Microsoft Word table

This is a bit of a forray into the unknown for me— I don't know a thing about applescript, but I managed to piece this working snippet together from various internet posts. Hope that it helps someone!

This script does the following:

  1. Prompts you to select a folder (should contain images)
  2. Finds the active Microsoft Word document
  3. Find the first table in the document
  4. Inserts first image from folder into row 2 of table
  5. Continues loop, inserting next image into next row

 

set imageFolder to (choose folder)

tell application "Finder" set imageList to files of folder imageFolder end tell

tell application "Microsoft Word" set thisStep to 0 repeat with imageFile in imageList repeat 1 times if name of imageFile is ".DS_Store" then exit repeat tell active document set x to text object of cell 2 of row (2 + thisStep) of table 1 make new inline picture at before x with properties {file name:imageFile as text, save with document:true} end tell end repeat set thisStep to thisStep + 1 end repeat

end tell

That's exactly what I was looking for - and I had it in front of my eyes:-)

Add new comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.