Function
Holidays(ByVal StartsOn As String, ByVal EndsOn As String, _
Location As String) As VariantLocation As String) As Variant
Dim appOutlook As Outlook.Application
Dim nSpace As Outlook.Namespace
Dim calFolder As Outlook.MAPIFolder
Dim calItem As Outlook.AppointmentItem
Dim filterItems As Outlook.Items
Dim strFilter As
Dim holName As New Collection
Dim holDate As New Collection
Dim i As
Dim aHoliday
Set appOutlook = CreateObject("Outlook.Application")
Set nSpace = appOutlook.GetNamespace("MAPI")
Set calFolder = nSpace.GetDefaultFolder(olFolderCalendar)
strFilter = "[Categories]= 'Holiday' And [Location]= '"
strFilter = strFilter & Location & "'" & " And [Start]>= '"
strFilter = strFilter & StartsOn & "'" & " And [End]<= '"
strFilter = strFilter & EndsOn & "'"
Set filterItems = calFolder.Items.Restrict(strFilter)
filterItems.Sort "[Start]", False
On Error Resume
For Each calItem In filterItems
holName.Add calItem.Subject, calItem.Subject
holDate.Add calItem.Start, CStr(calItem.Start)
Next
ReDim aHoliday(holName.Count - 1, 1)
For i = 0 To holName.Count - 1
aHoliday(i, 0) = holName.Item(i + 1)
aHoliday(i, 1) = holDate.Item(i + 1)
Next
Holidays = aHoliday
Set appOutlook =
Set nSpace =
Set calFolder =
Set calItem =
Set filterItems =
Set holName =
Set holDate = Nothing
End
Function
Function Holidays(InitialDate As String, EndDate As String,_Country As String) As VariantDim Holiday As New clsHolidays
Let Holidays = Holiday.Holidays(InitialDate, EndDate, Country)End Function