Я почти ничего не знаю о написании сценариев для Apple и был бы признателен за вашу помощь! Вот что я пытаюсь сделать:
Напишите сценарий, который копирует и вставляет ячейку Excel в слово, а затем автоматически сохраняет файл в формате PDF. Затем сценарий автоматизирует почтовую программу Apple для отправки набора электронных писем (с вложениями) на основе электронной таблицы Excel.
До сих пор я написал сценарий, который делает все это, за исключением того, что у меня возникли проблемы с повторением сценария со следующей ячейкой и так далее, пока все ячейки и электронные письма не будут выполнены. Вот что у меня есть до сих пор:
tell application "Microsoft Excel"
activate
set empName to string value of range "A4" of active sheet
set myVal to string value of range "P4" of active sheet
tell application "Finder"
set theFile to "Macintosh HD:users:deve:desktop:C.dotx"
tell application "Finder"
open file theFile
set the clipboard to myVal
tell application "Microsoft Word"
activate
tell application "System Events"
tell application process "Microsoft Word"
keystroke "v" using command down
keystroke "a" using command down
tell application "font" - this is just so I can fix a font issue (and I don't know how to do it using applescript so I made an automator program)
activate
delay 1
end tell
tell application "Microsoft Word"
save as active document file name "Macintosh HD:Users:Deve:Desktop:Materials for Applescript:CL:" & empName & " Letter.pdf" file format format PDF
end tell
tell application "Mail"
delay 2
set theMessage to make new outgoing message with properties {visible:true, subject:"Message", content:myVal}
tell theMessage
make new to recipient at end of to recipients with properties {name:empName, address:"[email protected]"}
end tell
tell theMessage
make new attachment with properties {file name:"Macintosh HD:Users:Deve:Desktop:Materials for Applescript:CL:" & empName & " Letter.pdf" as alias} at after the last paragraph
make new attachment with properties {file name:"Macintosh HD:Users:Deve:Desktop:Materials for Applescript:Work Book.pdf" as alias} at after the last paragraph
make new attachment with properties {file name:"Macintosh HD:Users:Deve:Desktop:Materials for Applescript:Picture File.pdf" as alias} at after the last paragraph
make new attachment with properties {file name:"Macintosh HD:Users:Deve:Desktop:Materials for Applescript:Lyrics.pdf" as alias} at after the last paragraph
make new attachment with properties {file name:"Macintosh HD:Users:Deve:Desktop:Materials for Applescript:Comparison.pdf" as alias} at after the last paragraph
make new attachment with properties {file name:"Macintosh HD:Users:Deve:Desktop:Materials for Applescript:Earlier Version.pdf" as alias} at after the last paragraph
end tell
end tell
end tell
end tell
end tell
end tell
end tell
end tell
Как бы я смог зациклить весь этот процесс так, чтобы ячейки каждый раз перемещались вниз, чтобы empName
и myVal
брали свои значения из A5
и P5
... затем A6
и P6
вплоть до 42?