Intento exportar el evento del calendario de Outlook seleccionado con Apple script pero aparece un error:
error : microsoft Outlook got an error : can't make vevent of calendar event id 5680 into type specifier
La secuencia de comandos está debajo
property byCategory : "By category"
property byPattern : "Names matching pattern"
property icsFormat : "VCalendar"
property outputFolderPath : the path to the desktop
-------------------------------------------
-- main
--
set calendarToExport to {}
-- Get the calendar selection
set calendarList to my ListCalendars()
display alert (count of calendarList)
if the (count of calendarList) is greater than 1 then
-- build calendar listing
set displayList to {}
repeat with c from 1 to the count of calendarList
set nextCal to calendarList's item c
set the end of displayList to {(c as text) & " - \"" & nextCal's cName & "\" (" & nextCal's cKind & ")"}
--display alert (c as text) & " - \"" & nextCal's cName & "\" (" & nextCal's cKind & ")"
end repeat
-- ask user to choose
set dResult to choose from list displayList with title "Choose Calendar(s)" with prompt "List Of Calendar:" OK button name "Export" with multiple selections allowed
-- generate chosen list
set chosenList to {}
repeat with nextItem in dResult
set the end of chosenList to (the first word of (nextItem as text) as number)
end repeat
if chosenList is not {} then
-- process each calendar chosen by the user
repeat with nextChoice in chosenList
set nextCal to calendarList's item nextChoice
set calendarToExport to ProcessCalendar(nextCal's cID, nextCal's cName, nextCal's cKind)
display alert (count of calendarToExport)
export_to_vcard(calendarToExport)
end repeat
end if
end if
--set calendarToExport to get_calendar_to_export()
--display alert (count of calendarToExport)
--if (count of calendarToExport) is 0 then
-- display alert "Please select calendar to export and rerun script" as warning
-- return
--end if
-- Shall we export to ics?
set theFormat to "VCalendar"
if theFormat is icsFormat then
-- export_to_ics(calendarToExport, theFormat)
else
display alert "Invalid format" as warning
end if
return
-------------------------------------------
-- get_calendar_to_export()
--
--
on ProcessCalendar(calID, calName, calKind)
tell application "Microsoft Outlook"
set thisCalendar to calendar id calID
set subjectList to every calendar event of thisCalendar
end tell
return subjectList
end ProcessCalendar
on ListCalendars()
set cals to {}
tell application "Microsoft Outlook"
repeat with nextCal in the every calendar
set the end of cals to {cID:nextCal's id, cName:nextCal's name, cKind:nextCal's class}
end repeat
end tell
return cals
end ListCalendars
on get_calendar_to_export()
set selectedCalendar to {}
tell application "Microsoft Outlook"
set theSelection to ListCalendars()
set testval to theSelection as string
display alert testval
if class of theSelection is list then
if class of the first item of theSelection is calendar then
copy theSelection to selectedCalendar
end if
else
if class of theSelection is calendar then
copy theSelection to selectedCalendar
end if
end if
--display alert selectedCalendar as text
return selectedCalendar
end tell
end get_calendar_to_export
-------------------------------------------
-------------------------------------------
-- export_to_ics()
--
--
on export_to_vcard(theCalendar)
set vcalendars to {}
tell application "Microsoft Outlook"
-- set myCounter to 1
repeat with aCalendar in theCalendar
-- set fileNew to ("a:mycountfinal.ics")
copy vevent of aCalendar to the end of vcalendars
end repeat
end tell
set myCounter to 1
repeat with aCard in vcalendars
set fileNew to ("a:MyCont" & myCounter as string) & ".ics"
set this_story to aCard
set this_file to (((path to desktop folder) as text) & fileNew)
my write_to_file(this_story, this_file, true)
set myCounter to myCounter + 1
end repeat
display alert "Complete"
end export_to_vcard
on write_to_file(this_data, target_file, append_data) -- (string, file path as string, boolean)
try
set the target_file to the target_file as text
set the open_target_file to ¬
open for access file target_file with write permission
if append_data is false then ¬
set eof of the open_target_file to 0
write this_data to the open_target_file starting at eof
close access the open_target_file
return true
on error
try
close access file target_file
end try
return false
end try
end write_to_file -------------------------------------------
-- replace_text()
on replace_text(sourceStr, searchString, replaceString)
set searchStr to (searchString as text)
set replaceStr to (replaceString as text)
set sourceStr to (sourceStr as text)
set saveDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to (searchString)
set theList to (every text item of sourceStr)
set AppleScript's text item delimiters to (replaceString)
set theString to theList as string
set AppleScript's text item delimiters to saveDelims
return theString
end replace_text