我幾乎不知道蘋果腳本,並希望得到您的幫助!這裏是我想要做的事:重複在變量範圍內循環的腳本
編寫一個腳本,複製和粘貼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?
祝賀你的第一篇文章。改變標題來表達你的具體問題 - 重複一個腳本循環的變量範圍。不要用大寫字母作爲重點,它讓很多人只是跳過你的問題,好的是你已經發布了一些工作代碼,你仍然可以重構一下,因爲水平滾動條不鼓勵深入分析。那麼什麼是錯的。它有助於獲得有用的答案。歡迎來到StackOverflow Deve。 – 2014-10-19 01:16:25