Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

How Do You Write VBA Code To Access Calendar Data In Microsoft Outlook?

0
Posted

How Do You Write VBA Code To Access Calendar Data In Microsoft Outlook?

0

• In this example, we will access a calendar named “Cox”. It is located in the “My Calendars” folder of my Outlook application. • The code is as follows: • Public Sub ReadCalendar(name As String, outputFile as String) • Set myOlApp = CreateObject(“Outlook.Application”) • Set myNameSpace = myOlApp.GetNamespace(“MAPI”) • Set MyFolder = myNameSpace.GetDefaultFolder(olFolderCalendar) • Set myNewFolder = MyFolder.Folders(name) • Dim oItems As Outlook.Items • Set oItems = myNewFolder.Items • oItems.Sort “[Start]” • Dim ret As String • For Each oAppt In oItems • ret = ret + oAppt.Subject • ret = ret + Chr(9) + Str$(DatePart(“m”, oAppt.Start)) + “/” + Str$(DatePart(“d”, oAppt.Start)) + “-” • ret = ret + Str$(DatePart(“m”, oAppt.End)) + “/” + Str$(DatePart(“d”, oAppt.End)) + “/” + Str$(DatePart(“yyyy”, oAppt.End)) • ret = ret + Chr(13) + Chr(10) • Next • MsgBox (ret) • Open outputFile For Output As #1 • For Each oAppt In oItems • ret = ret + oAppt.Subject • ret = ret + Chr(9) + Str$(DatePart(“m

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123