[FONT=Courier New][SIZE=1]Option Explicit[/SIZE][/FONT]
[FONT=Courier New][SIZE=1] [/SIZE][/FONT]
[FONT=Courier New][SIZE=1]Public Sub Driver()[/SIZE][/FONT]
[FONT=Courier New][SIZE=1] [/SIZE][/FONT]
[FONT=Courier New][SIZE=1] Call GetAppointments( _[/SIZE][/FONT]
[FONT=Courier New][SIZE=1] DateValue("01/02/2011") + TimeValue("08:00:00"), _[/SIZE][/FONT]
[FONT=Courier New][SIZE=1] DateValue("28/02/2011") + TimeValue("18:00:00"))[/SIZE][/FONT]
[FONT=Courier New][SIZE=1] [/SIZE][/FONT]
[FONT=Courier New][SIZE=1]End Sub[/SIZE][/FONT]
[FONT=Courier New][SIZE=1] [/SIZE][/FONT]
[FONT=Courier New][SIZE=1]Public Sub GetAppointments(ByVal argStartDate As Date, ByVal argEndDate As Date)[/SIZE][/FONT]
[FONT=Courier New][SIZE=1] [/SIZE][/FONT]
[FONT=Courier New][SIZE=1] Dim oApp As Outlook.Application[/SIZE][/FONT]
[FONT=Courier New][SIZE=1] Dim oNameSpace As Outlook.Namespace[/SIZE][/FONT]
[FONT=Courier New][SIZE=1] Dim oApptItem As Outlook.AppointmentItem[/SIZE][/FONT]
[FONT=Courier New][SIZE=1] Dim oFolder As Outlook.MAPIFolder[/SIZE][/FONT]
[FONT=Courier New][SIZE=1] Dim oMeetingoApptItem As Outlook.MeetingItem[/SIZE][/FONT]
[FONT=Courier New][SIZE=1] Dim oObject As Object[/SIZE][/FONT]
[FONT=Courier New][SIZE=1] [/SIZE][/FONT]
[FONT=Courier New][SIZE=1] Dim sErrorMessage As String[/SIZE][/FONT]
[FONT=Courier New][SIZE=1] [/SIZE][/FONT]
[FONT=Courier New][SIZE=1] Dim irow As Long[/SIZE][/FONT]
[FONT=Courier New][SIZE=1] [/SIZE][/FONT]
[FONT=Courier New][SIZE=1] On Error Resume Next[/SIZE][/FONT]
[FONT=Courier New][SIZE=1] ' check if Outlook is running[/SIZE][/FONT]
[FONT=Courier New][SIZE=1] Set oApp = GetObject("Outlook.Application")[/SIZE][/FONT]
[FONT=Courier New][SIZE=1] If Err <> 0 Then[/SIZE][/FONT]
[FONT=Courier New][SIZE=1] 'if not running, start it[/SIZE][/FONT]
[FONT=Courier New][SIZE=1] Set oApp = CreateObject("Outlook.Application")[/SIZE][/FONT]
[FONT=Courier New][SIZE=1] End If[/SIZE][/FONT]
[FONT=Courier New][SIZE=1] [/SIZE][/FONT]
[FONT=Courier New][SIZE=1]' On Error GoTo Err_Handler[/SIZE][/FONT]
[FONT=Courier New][SIZE=1] [/SIZE][/FONT]
[FONT=Courier New][SIZE=1] Set oNameSpace = oApp.GetNamespace("MAPI")[/SIZE][/FONT]
[FONT=Courier New][SIZE=1] Set oFolder = oNameSpace.GetDefaultFolder(olFolderCalendar)[/SIZE][/FONT]
[FONT=Courier New][SIZE=1] [/SIZE][/FONT]
[FONT=Courier New][SIZE=1] Rows("2:" & CStr(Rows.Count)).ClearContents[/SIZE][/FONT]
[FONT=Courier New][SIZE=1] irow = 1[/SIZE][/FONT]
[FONT=Courier New][SIZE=1] [/SIZE][/FONT]
[FONT=Courier New][SIZE=1] For Each oObject In oFolder.Items[/SIZE][/FONT]
[FONT=Courier New][SIZE=1] If oObject.Class = olAppointment Then[/SIZE][/FONT]
[FONT=Courier New][SIZE=1] Set oApptItem = oObject[/SIZE][/FONT]
[FONT=Courier New][SIZE=1] If oApptItem.Start >= argStartDate And oApptItem.Start <= argEndDate Then[/SIZE][/FONT]
[FONT=Courier New][SIZE=1] irow = irow + 1[/SIZE][/FONT]
[FONT=Courier New][SIZE=1] Cells(irow, 1) = Format(oApptItem.Start, "dd/mm/yyyy")[/SIZE][/FONT]
[FONT=Courier New][SIZE=1] Cells(irow, 2) = Format(oApptItem.Start, "hh:nn")[/SIZE][/FONT]
[FONT=Courier New][SIZE=1] Cells(irow, 3) = oApptItem.Duration[/SIZE][/FONT]
[FONT=Courier New][SIZE=1] Cells(irow, 4) = oApptItem.Subject[/SIZE][/FONT]
[FONT=Courier New][SIZE=1] Cells(irow, 5) = oApptItem.Location[/SIZE][/FONT]
[FONT=Courier New][SIZE=1] End If[/SIZE][/FONT]
[FONT=Courier New][SIZE=1] End If[/SIZE][/FONT]
[FONT=Courier New][SIZE=1] Next oObject[/SIZE][/FONT]
[FONT=Courier New][SIZE=1] [/SIZE][/FONT]
[FONT=Courier New][SIZE=1] Set oApp = Nothing[/SIZE][/FONT]
[FONT=Courier New][SIZE=1] Set oNameSpace = Nothing[/SIZE][/FONT]
[FONT=Courier New][SIZE=1] Set oApptItem = Nothing[/SIZE][/FONT]
[FONT=Courier New][SIZE=1] Set oFolder = Nothing[/SIZE][/FONT]
[FONT=Courier New][SIZE=1] Set oObject = Nothing[/SIZE][/FONT]
[FONT=Courier New][SIZE=1] [/SIZE][/FONT]
[FONT=Courier New][SIZE=1] Exit Sub[/SIZE][/FONT]
[FONT=Courier New][SIZE=1] [/SIZE][/FONT]
[FONT=Courier New][SIZE=1]Err_Handler:[/SIZE][/FONT]
[FONT=Courier New][SIZE=1] sErrorMessage = Err.Number & " " & Err.Description[/SIZE][/FONT]
[FONT=Courier New][SIZE=1] [/SIZE][/FONT]
[FONT=Courier New][SIZE=1]End Sub[/SIZE][/FONT]