So this is first script I've tried so far, the objective of which is to set up a drag and drop folder that takes info from an excel workbook, copies it into an illustrator document, and then saves a pdf of it. The problem I'm running into now is how to make sure it runs only on excel files. I'm thinking the extension condition needs to be under an application tell (no logic behind that really, just how I've seen it everywhere else), but then it seem I would have to place that condition under every tell. Seems like there should be a better way. Any help would be greatly appreciated!
Code:
property application_extension_list : {"xlsx", "xls"}
on adding folder items to this_folder after receiving added_items
try
repeat with i from 1 to number of items in added_items
if (the name extension of the (item i of added_items) is in the application_extension_list) then
tell application "Microsoft Excel"
activate
open item i of added_items
copy range (range "A3")
close active workbook saving no
end tell
set fp to this_folder & ":Output:" & (the clipboard) & ".pdf" as string
tell application "Adobe Illustrator"
activate
open "/Users/karen_r/Desktop/TestDragDrop/Resources/testtemp.ai"
set (contents of words of every line of every text frame in document 1 whose contents is "name") to the clipboard
save current document in file fp as pdf ¬
with options {class:PDF save options ¬
, compatibility:Acrobat 5 ¬
, preserve editability:true}
close current document saving no
end tell
tell application "Finder"
activate
duplicate item i of added_items to folder ("mac hd:Users:karen_r:Desktop:TestDragDrop:Output" as alias) with replacing
delete item i of added_items
end tell
end if
end repeat
on error
return
end try
end adding folder items to
Last edited by a moderator: