Re: PASSING MS OUTLOOK DATA TO EXCEL
Andy Pope
Hi,
This will pull calander information from Outlook into the activesheet in excel.
Remember to include a reference to the Outlook library. Within VBE use Tools > References.
Sub GetOLCalander()
'
' requires reference to Outlook Library
'
Dim olApp As Outlook.Application
Dim objNameSpace As Outlook.Namespace
Dim olItem As Outlook.AppointmentItem
Dim lngRow As Long
Set olApp = CreateObject("Outlook.Application")
Set objNameSpace = olApp.GetNamespace("MAPI")
ActiveSheet.Range("A1:C1") = Array("Subject", "Start", "Finish")
lngRow = 2
For Each olItem In objNameSpace.GetDefaultFolder(olFolderCalendar).Items
With ActiveSheet
.Cells(lngRow, 1).Value = olItem.Subject
.Cells(lngRow, 2).Value = olItem.Start
.Cells(lngRow, 3).Value = olItem.End
End With
lngRow = lngRow + 1
Next
Set objNameSpace = Nothing
Set olApp = Nothing
End Sub