0

I'm working on a project where I need to somehow access the contents of a table embedded in an Outlook invite programmatically. If it were in an email, I'd be dealing with an object of the class "MailItem" and I could call HTMLBody and use the "table" tags to get the contents. However, to my knowledge, no similar functionality exists for "AppointmentItem" objects. I know that there is the "RTFBody" function for MailItems, but I'm completely at a loss as to how to get the contents of the table using RTF and Google isn't very helpful on this front. For my purposes, the table in the Outlook invite can either be an embedded Excel Worksheet object, or simply a table you can insert by going to Insert | Table.

My end goal is to get the contents of tables embedded in a shared team calendar and send them to an Excel worksheet where I've built a dashboard of meetings my team has. The contents of the tables embedded in the Outlook invites on the team calendar have datapoints that I'd like to have show up dynamically in the dashboard.

Any help would be greatly, greatly appreciated - Thanks!

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Michael
  • 57
  • 1
  • 4
  • Isn't this the same question as asked before: http://stackoverflow.com/questions/37014913/htmlbody-workaround-for-olappointment-object? Furthermore, it seems that there is another using having the exact same problem here (just now): http://stackoverflow.com/questions/37025009/vba-outlook-appointment#comment61615861_37025009 Maybe you can work it out together? – Ralph May 04 '16 at 18:01
  • I am unclear what "access" means in your question. (1) Are you receiving appointments that contain RTF bodies that you wish to extract and process? (2) Do you have a table in Excel which you wish to distribute as part of an `AppointmentItem`? If (2), why not distribute the Excel workbook as an attachment? – Tony Dallimore May 04 '16 at 21:54
  • Thanks both for your replies. Tony - by "access" I simply mean get the values stored in the relevant cells of the table. – Michael May 05 '16 at 17:26
  • So you want to write to the `AppointmentItem`. I tried outputting RTF many years ago and totally failed. As far as I could determine at the time, there were no helpful functions. It was up to the programmer to create a valid RTF string and output to RTFBody. Why isn't an attached Excel workbook an acceptable solution? – Tony Dallimore May 05 '16 at 18:56
  • This might point you in the right direction: [HTMLBody Workaround For OlAppointment Object?](https://stackoverflow.com/questions/37014913/htmlbody-workaround-for-olappointment-object/46933216#46933216) – Big Dude Oct 25 '17 at 13:30

1 Answers1

0

Can you try this?

Private Sub Add_Appointments_To_Outlook_Calendar()

    'Include Microsoft Outlook nn.nn Object Library from Tools -> References
    Dim oAppt As AppointmentItem
    Dim Remind_Time As Double

    i = 2
    Subj = ThisWorkbook.Sheets(1).Cells(i, 1)

    'Loop through entire list of Reminders to be added
    While Subj <> ""
        Set oAppt = Outlook.Application.CreateItem(olAppointmentItem)

        oAppt.Subject = Subj
        oAppt.Location = ThisWorkbook.Sheets(1).Cells(i, 2)
        oAppt.Start = ThisWorkbook.Sheets(1).Cells(i, 3)
        Remind_Time = ThisWorkbook.Sheets(1).Cells(i, 4) * 1 * 60
        oAppt.ReminderMinutesBeforeStart = Remind_Time
        oAppt.AllDayEvent = True
        oAppt.Save

        i = i + 1
        Subj = ThisWorkbook.Sheets(1).Cells(i, 1)
    Wend
    MsgBox "Reminder(s) Added To Outlook Calendar"

End Sub

' The code comes from this link:

http://officetricks.com/add-appointment-to-outlook-calendar-through-excel-macro-vba/

I actually wrote a book about this, and so many other things. You can find it at the link below.

https://www.amazon.com/Automating-Business-Processes-Reducing-Increasing-ebook/dp/B01DJJKVZC?ie=UTF8&keywords=ryan%20shuell&qid=1463837322&ref_=sr_1_1&sr=8-1

ASH
  • 20,759
  • 19
  • 87
  • 200