最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

All calendar events from outlook and transferring to an excel file using apple script - Stack Overflow

matteradmin6PV0评论

first time I am using apple script and it isn't running the excel file part, could anyone point me in the right direction, it keeps point to the start time. I am trying to achieve get the event meetings and appointments for the calendar into a file on excel.

tell application "Microsoft Outlook"
    -- Get all calendars in Outlook
    set allCalendars to calendars
   
    -- Choose a specific calendar (the first one as an example)
    set selectedCalendar to item 1 of allCalendars
   
    -- Get all calendar events in the selected calendar
    set calendarEvents to calendar events of selectedCalendar
   
    -- Start Excel
    tell application "Microsoft Excel"
        activate
        set newWorkbook to make new workbook
        set newSheet to active sheet of newWorkbook
       
        -- Write headers
        set value of cell "A1" of newSheet to "Meeting Name"
        set value of cell "B1" of newSheet to "Date"
        set value of cell "C1" of newSheet to "Reoccurrence"
        set value of cell "D1" of newSheet to "Attendees"
       
        -- Write event details starting from the second row
        set rowIndex to 2
        repeat with anEvent in calendarEvents
            set eventName to subject of anEvent
            set eventDate to start time of anEvent
            set isRecurring to recurring of anEvent
            set attendeeList to ""
           
            -- Get attendees
            if (exists required attendees of anEvent) then
                set requiredAttendees to required attendees of anEvent
                repeat with anAttendee in requiredAttendees
                    set attendeeList to attendeeList & name of anAttendee & ", "
                end repeat
                -- Remove the trailing comma and space
                if (length of attendeeList > 2) then
                    set attendeeList to text 1 thru -3 of attendeeList
                end if
            end if
           
            -- Write details to Excel
            set value of cell ("A" & rowIndex) of newSheet to eventName
            set value of cell ("B" & rowIndex) of newSheet to (eventDate as string)
            set value of cell ("C" & rowIndex) of newSheet to (isRecurring as string)
            set value of cell ("D" & rowIndex) of newSheet to attendeeList
           
            set rowIndex to rowIndex + 1
        end repeat
    end tell
end tell

-- Notify user that the export is complete
display dialog "Export to Excel completed!" with title "Success" buttons {"OK"} default button "OK"

Explanation:

  • Meeting Name (A): The subject of the meeting.
  • Date (B): The start date and time of the meeting.
  • Recurrence (C): Indicates if the meeting is recurring (true or false).
  • Attendees (D): A comma-separated list of required attendees.
Post a comment

comment list (0)

  1. No comments so far