I am trying to make a script (mind you I have ZERO knowledge of what I am doing) that will take certain information from my excel documents and make new calendars with events in iCal.
basically…i have a schedule thats made from a template I created in excel. Everyone in the factories and company uses the same template now…so i cant adjust anything on there.
The schedule has the project name, the revision date, the 22 stages of development and the date each stage is ready
I want to make a new calendar in iCal with the name of the Project, and a new event for each of those stages.
here is the code i have so far:
tell application "Microsoft Excel"
set ProjectName to the value of cell "$F$4" as string
set FirstTargetDate to the value of cell "$D$12"
set FirstTargetName to "All Tooling Patterns in HK" as string
set SecondTargetDate to the value of cell "$E$12"
set SecondTargetName to "Rough Ceramics" as string
set ThirdTargetDate to the value of cell "$F$12"
set ThirdTargetName to "Tooling Quote Submitted" as string
set FourthTargetDate to the value of cell "$G$12"
set FourthTargetName to "Casting Ceramics" as string
set FifthTargetDate to the value of cell "$H$12"
set FifthTargetName to "Approval of Casting Ceramics" as string
set SixthTargetDate to the value of cell "$I$12"
set SixthTargetName to "Rough Ceramics to Tempe" as string
set SeventhTargetDate to the value of cell "$J$12"
set SeventhTargetName to "Tooling PO in HK" as string
set EighthTargetDate to the value of cell "$L$12"
set EighthTargetName to "Paintmaster in HK" as string
set NinthTargetDate to the value of cell "$M$12"
set NinthTargetName to "Production Quote Submitted" as string
set TenthTargetDate to the value of cell "$N$12"
set TenthTargetName to "Production Facility Confirmed" as string
set EleventhTargetDate to the value of cell "$O$12"
set EleventhTargetName to "1st Shot Samples" as string
set TwelthTargetDate to the value of cell "$P$12"
set TwelthTargetName to "Blister Layout in HK" as string
set ThirteenthTargetDate to the value of cell "$Q$12"
set ThirteenthTargetName to "1st Deco Samples" as string
set FourteenthTargetDate to the value of cell "$R$12"
set FourteenthTargetName to "Mock-up Packaging Samples" as string
set FifteenthTargetDate to the value of cell "$S$12"
set FifteenthTargetName to "EP Samples" as string
set SixteenthTargetDate to the value of cell "$T$12"
set SixteenthTargetName to "Packaging Artwork in HK" as string
set SeventeenthTargetDate to the value of cell "$U$12"
set SeventeenthTargetName to "Production PO in HK" as string
set EighteenthTargetDate to the value of cell "$V$12"
set EighteenthTargetName to "Release Printing" as string
set NineteenthTargetDate to the value of cell "$W$12"
set NineteenthTargetName to "Release Injection" as string
set TwentythTargetDate to the value of cell "$X$12"
set TwentythTargetName to "Release Decoration" as string
set TwentyFirstTargetDate to the value of cell "$Y$12"
set TwentyFirstTargetName to "PP Samples" as string
set TwentySecondTargetDate to the value of cell "$Z$12"
set TwentySecondTargetName to "1st Shipment" as string
set TwentyThirdTargetDate to the value of cell "$K$12"
set TwentyThirdTargetName to "Tooling Start" as string
end tell
tell application "iCal"
activate
set theCal to make new calendar at end of calendars with properties {title:ProjectName}
tell theCal
if (FirstTargetDate is not "N/A" and FirstTargetDate is not "") then
set theEvent to make new event at end of events with properties {start date:FirstTargetDate, summary:FirstTargetName, allday event:true, status:confirmed}
end if
if (SecondTargetDate is not "N/A" and SecondTargetDate is not "") then
set theEvent to make new event at end of events with properties {start date:SecondTargetDate, summary:SecondTargetName, allday event:true, status:confirmed}
end if
if (ThirdTargetDate is not "N/A" and ThirdTargetDate is not "") then
set theEvent to make new event at end of events with properties {start date:ThirdTargetDate, summary:ThirdTargetName, allday event:true, status:confirmed}
end if
if (FourthTargetDate is not "N/A" and FourthTargetDate is not "") then
set theEvent to make new event at end of events with properties {start date:FourthTargetDate, summary:FourthTargetName, allday event:true, status:confirmed}
end if
if (FifthTargetDate is not "N/A" and FifthTargetDate is not "") then
set theEvent to make new event at end of events with properties {start date:FifthTargetDate, summary:FifthTargetName, allday event:true, status:confirmed}
end if
if (SixthTargetDate is not "N/A" and SixthTargetDate is not "") then
set theEvent to make new event at end of events with properties {start date:SixthTargetDate, summary:SixthTargetName, allday event:true, status:confirmed}
end if
if (SeventhTargetDate is not "N/A" and SeventhTargetDate is not "") then
set theEvent to make new event at end of events with properties {start date:SeventhTargetDate, summary:SeventhTargetName, allday event:true, status:confirmed}
end if
if (EighthTargetDate is not "N/A" and EighthTargetDate is not "") then
set theEvent to make new event at end of events with properties {start date:EighthTargetDate, summary:EighthTargetName, allday event:true, status:confirmed}
end if
if (NinthTargetDate is not "N/A" and NinthTargetDate is not "") then
set theEvent to make new event at end of events with properties {start date:NinthTargetDate, summary:NinthTargetName, allday event:true, status:confirmed}
end if
if (TenthTargetDate is not "N/A" and TenthTargetDate is not "") then
set theEvent to make new event at end of events with properties {start date:TenthTargetDate, summary:TenthTargetName, allday event:true, status:confirmed}
end if
if (EleventhTargetDate is not "N/A" and EleventhTargetDate is not "") then
set theEvent to make new event at end of events with properties {start date:EleventhTargetDate, summary:EleventhTargetName, allday event:true, status:confirmed}
end if
if (TwelthTargetDate is not "N/A" and TwelthTargetDate is not "") then
set theEvent to make new event at end of events with properties {start date:TwelthTargetDate, summary:TwelthTargetName, allday event:true, status:confirmed}
end if
if (ThirteenthTargetDate is not "N/A" and ThirteenthTargetDate is not "") then
set theEvent to make new event at end of events with properties {start date:ThirteenthTargetDate, summary:ThirteenthTargetName, allday event:true, status:confirmed}
end if
if (FourteenthTargetDate is not "N/A" and FourteenthTargetDate is not "") then
set theEvent to make new event at end of events with properties {start date:FourteenthTargetDate, summary:FourteenthTargetName, allday event:true, status:confirmed}
end if
if (FifteenthTargetDate is not "N/A" and FifteenthTargetDate is not "") then
set theEvent to make new event at end of events with properties {start date:FifteenthTargetDate, summary:FifteenthTargetName, allday event:true, status:confirmed}
end if
if (SixteenthTargetDate is not "N/A" and SixteenthTargetDate is not "") then
set theEvent to make new event at end of events with properties {start date:SixteenthTargetDate, summary:SixteenthTargetName, allday event:true, status:confirmed}
end if
if (SeventeenthTargetDate is not "N/A" and SeventeenthTargetDate is not "") then
set theEvent to make new event at end of events with properties {start date:SeventeenthTargetDate, summary:SeventeenthTargetName, allday event:true, status:confirmed}
end if
if (EighteenthTargetDate is not "N/A" and EighteenthTargetDate is not "") then
set theEvent to make new event at end of events with properties {start date:EighteenthTargetDate, summary:EighteenthTargetName, allday event:true, status:confirmed}
end if
if (NineteenthTargetDate is not "N/A" and NineteenthTargetDate is not "") then
set theEvent to make new event at end of events with properties {start date:NineteenthTargetDate, summary:NineteenthTargetName, allday event:true, status:confirmed}
end if
if (TwentythTargetDate is not "N/A" and TwentythTargetDate is not "") then
set theEvent to make new event at end of events with properties {start date:TwentythTargetDate, summary:TwentythTargetName, allday event:true, status:confirmed}
end if
if (TwentyFirstTargetDate is not "N/A" and TwentyFirstTargetDate is not "") then
set theEvent to make new event at end of events with properties {start date:TwentyFirstTargetDate, summary:TwentyFirstTargetName, allday event:true, status:confirmed}
end if
if (TwentySecondTargetDate is not "N/A" and TwentySecondTargetDate is not "") then
set theEvent to make new event at end of events with properties {start date:TwentySecondTargetDate, summary:TwentySecondTargetName, allday event:true, status:confirmed}
end if
end tell
quit
end tell
Here is the problems I need help with:
-
After I the calendar is successfully created, I can only see the new calendar, but no events. After I restart iCal, then the events appear. Is there any way to refresh the calendars or restart iCal? I can get iCal to quit…but not launch again.
-
Is there a way to have the script check iCal and see if there is a Calendar already there with the same ProjectName. If yes, then it would delete that calendar and make a new one, if no, then it would continue to create a new calendar.
-
How do I specify the calendar color?
-
How do I specify the information for “Notes” for the event?
Model: intel iMac 20"
AppleScript: 1.10.7
Browser: Safari 419.3
Operating System: Mac OS X (10.4)