Hi there,
I am using this macro to import my outlook Calendar into excel but it is ignoring recurrent meetings and only shows the first instance.
Is there a way I can add this into the code? All my attempts have failed so far.
I am using this macro to import my outlook Calendar into excel but it is ignoring recurrent meetings and only shows the first instance.
Is there a way I can add this into the code? All my attempts have failed so far.
Code:
Sub Listappointments()
Dim olApp As Object
Dim olNS As Object
Dim olFolder As Object
Dim olapt As Object
Dim NextRow As Long
Dim FromDate As Date
Dim ToDate As Date
FromDate = Range("H1")
ToDate = Range("I1")
On Error Resume Next
Set olApp = GetObject(, "Outlook.Application")
If Err.Number > 0 Then Set olApp = CreateObject("Outlook.application")
On Error GoTo 0
Set olNS = olApp.GetNamespace("MAPI")
Set olFolder = olNS.GetDefaultFolder(9) 'olFolderCalendar
NextRow = 2
With Sheets("Sheet1") 'Change the name of the sheet here
.Range("A1:D1").Value = Array("Project", "Date", "Time spent", "Location")
For Each olapt In olFolder.Items
If (olapt.Start >= FromDate And olapt.Start <= ToDate) Then
.Cells(NextRow, "A").Value = olapt.Subject
.Cells(NextRow, "B").Value = CDate(olapt.Start)
.Cells(NextRow, "C").Value = olapt.End - olapt.Start
.Cells(NextRow, "C").NumberFormat = "HH:MM"
.Cells(NextRow, "D").Value = olapt.Location
.Cells(NextRow, "E").Value = olapt.Categories
.Cells(NextRow, "F").Value = olapt.Requiredattendees
NextRow = NextRow + 1
Else
End If
Next olapt
End With
Set olapt = Nothing
Set olFolder = Nothing
Set olNS = Nothing
Set olApp = Nothing
End Sub