I have a script i made previously in Leopard, but now i am running Snow Leopard. Its idea is to be run from Excel’s script menu and it will convert schedules in excel documents into ical todos. I tried making a few adjustments, and dont know what happened…but it stopped working yesterday.
-
Can someone look at below script and advise how to fix? it runs OK if it is creating a new calendar (ProjectName), but if there is an existing calendar (ProjectName) then it fails to make any updates to the new dates.
-
Is there any way to add something to transfer notes/urls when updating existing calendars? I sometimes manually add in urls (to emails) or notes to the todo’s, but when i ran this script in past it would lose the notes/urls when changing the date i think.
sample milestone in xls:
http://rapidshare.com/files/331104488/Test.xls.html
property summaryList : {"Rough Ceramics", "Tooling Quote", "Casting Ceramics", "Tooling PO", "Release Casting", "Paint Photos", "Layout", "Vendor", "Paint Guides/Master", "Decals", "1st Shots", "Chase Decals/Guide", "Mockup", "Packaging Files", "Chromalin", "EP", "1st Deco", "Proofs", "PO", "Chase 1st Deco", "Printing Release", "Blister Release", "Injection Release", "Deco Release", "Deco Breakdown", "PP"}
tell application "Microsoft Excel"
set ProjectName to the value of cell "$F$4"
set ReviseDate to the value of cell "$AD$4"
set range_value to item 1 of (get value of range "E12:Y12")
set {RoughCeramics, ToolQuote, Casting, CastingApp, ToolPO, blind, PaintPhoto, Layout, blind, VendorConfirm, PaintMaster, FirstShot, Mockup, Packaging, EP, FirstDeco, PO, ReleasePrint, ReleaseInject, ReleaseDeco, PP} to range_value
close front window
end tell
tell application "iCal"
if not (exists calendar ProjectName) then
tell (make new calendar at end of calendars with properties {name:ProjectName, description:ReviseDate as text})
set its color to {13500, 28500, 48500}
end tell
end if
set dateList to {RoughCeramics, ToolQuote, Casting, ToolPO, CastingApp, PaintPhoto, Layout, VendorConfirm, PaintMaster, PaintMaster, FirstShot, FirstShot, Mockup, Packaging, Packaging, EP, FirstDeco, Packaging, PO, FirstDeco, ReleasePrint, ReleasePrint, ReleaseInject, ReleaseDeco, ReleaseDeco, PP}
repeat with i from 1 to count summaryList
set theDate to my calcDate(item i of dateList)
set {theTodo, isCompleted} to my check_Todo(ProjectName, item i of summaryList)
if class of theDate is date then
if item i of summaryList is "Proofs" then set theDate to theDate + 1 * weeks
if item i of summaryList is "Chase Decals/Guide" then set theDate to theDate + 2 * weeks
if item i of summaryList is "Chase 1st Deco" then set theDate to theDate + 2 * weeks
if theTodo is false or (item i of summaryList is "Proofs" and isCompleted is false) or (item i of summaryList is "Chase Decals/Guide" and isCompleted is false) or (item i of summaryList is "Chase 1st Deco" and isCompleted is false) then
if item i of summaryList is "Proofs" and theTodo is not false then delete theTodo
if item i of summaryList is "Chase Decals/Guide" and theTodo is not false then delete theTodo
if item i of summaryList is "Chase 1st Deco" and theTodo is not false then delete theTodo
make new todo at end of todos of calendar ProjectName with properties {due date:theDate, description:ProjectName, summary:item i of summaryList}
else
if isCompleted is false then set due date of theTodo to theDate
end if
end if
end repeat
end tell
on calcDate(d)
if class of d is date then return d
if d is "" or d is in {"N/A", "NA", "on hold"} then return false
set delim to item (((d contains "/") as integer) + 1) of {".", "/"}
set {TID, text item delimiters} to {text item delimiters, delim}
try
set {mn, dy, yr} to text items of d
set yr to yr mod 1000 + 2000
set text item delimiters to TID
tell (current date) to set d to it - (its time)
tell d to set {its day, its month, its year} to {dy as integer, mn as integer, yr as integer}
return d
on error
set text item delimiters to TID
return false
end try
end calcDate
on check_Todo(cal, param)
tell application "iCal"
tell calendar cal
repeat with tt in (get todos)
tell contents of tt
if summary is param then
set c to completion date
try
c
return {it, true}
on error
return {it, false}
end try
end if
end tell
end repeat
end tell
return {false, false}
end tell
end check_Todo