Title: Exporting Events
I've adapted the following script (I’m not sure who wrote the original I’m afraid) to export calendar events from Entourage. It asks for the dates between which you want events exported and it works quite well.
The only problem is that if I have typed a return within the notes section of the event the following text is treated as a new record in the excel worksheet.
I think what needs to be done is for all the returns in the event to be replaced with non-breaking returns. Does anybody know if this is possible to do with the applescript or would I have to do it in Excel itself? Is it something to do with the text item delimiters, I’m not sure what they do?
Thanks
Aaron
set resultDate to display dialog ¬
"Date to start from:" default answer ""
set startResult to text returned of resultDate
set startdate to date (startResult)
set resultDate to display dialog ¬
"Date to finish at (inclusive) :" default answer ""
set EndResult to text returned of resultDate
set EndDate to (date (EndResult)) + 1 * days -- to be inclusive
set RowNum to 1
set ods to AppleScript's text item delimiters -- the default {""} normally
set AppleScript's text item delimiters to {", "}
tell application "Microsoft Excel"
Activate
Create New Workbook
tell Application "Microsoft Entourage"
set searchResults to every event whose start time ¬
is greater than startdate and ¬
start time is less than EndDate
if (count of searchResults) > 1 then
repeat with theEvent in searchResults
set sStart to start time of theEvent
set EEnd to end time of theEvent
set Ssubject to subject of theEvent
set Lloc to location of theEvent
set Desc to content of theEvent
set theCats to category of theEvent
if theCats = {} then
set catNames to "None"
else
set catNames to {}
repeat with aCat in theCats
set end of catNames to name of aCat
end repeat
set catNames to catNames as string
end if
set sRange to "r" & RowNum & "c1:r" & RowNum & "c8"
tell application "Microsoft Excel" to set FormulaR1C1 of Range sRange to {Ssubject, sStart, catNames, Lloc, sStart, EEnd, "=(rc[-1]-rc[-2])", Desc}
set RowNum to RowNum + 1
end repeat
end if
tell application "Microsoft Excel"
Select Range "C2"
set NumberFormat of Selection to "d/m/yyyy"
Select Range "C5:C6"
set NumberFormat of Selection to "h:mm AM/PM"
Select Range "C7"
set NumberFormat of Selection to "h:mm"
set AppleScript's text item delimiters to ods -- restore delimeters
end tell
end tell
end tell
- Exporting Events Aaron Sills
- Re: Exporting Events Aaron Sills
- Re: Exporting Events Allen Watson
