Sub
FindTermine()
Dim
olApp
As
Object
:
Set
olApp = CreateObject(
"Outlook.Application"
)
Dim
olNS
As
Outlook.NameSpace:
Set
olNS = olApp.GetNamespace(
"MAPI"
)
Dim
olApt
As
Object
Dim
NextRow
As
Long
Dim
FromDate
As
Date
Dim
ToDate
As
Date
Dim
ws
As
Worksheet:
Set
ws = ThisWorkbook.Sheets(
"Import"
)
Dim
myAppointments
As
Outlook.Items
Dim
objOwner
As
Object
:
Set
objOwner = olNS.CreateRecipient(AvailableCals.Value)
FromDate =
CDate
(MonBox.Value)
ToDate =
CDate
(EndDate.Caption)
On
Error
Resume
Next
If
Err.Number > 0
Then
Set
olApp = CreateObject(
"Outlook.Application"
)
objOwner.Resolve
If
objOwner.Resolved
Then
Set
myAppointments = olNS.GetSharedDefaultFolder(objOwner, olFolderCalendar).Items
End
If
myAppointments.Sort
"[Start]"
myAppointments.IncludeRecurrences =
True
Set
olApt = myAppointments.Find(
"[Start] >= "
""
& _
FromDate &
""
" and [Start] <= "
""
& ToDate &
""
""
)
While
TypeName(olApt) <>
"Nothing"
MsgBox objOwner &
" - "
& olApt.Subject &
" - "
&
CDate
(olApt.Start) &
" - "
&
CDate
(olApt.
End
) _
_
&
" - "
& Format(olApt.
End
- olApt.Start,
"0.00"
) &
" - "
& olApt.Location
Set
olApt = myAppointments.FindNext
Wend
End
Sub