HiI found this code on forum, it works quite well…however, it appears that one has to manually enter the holidays…how would/could I incorporate a lookup to a view with all the holidays and it would automatically deduct the day if chosen?
Many thanks.
Coll
Here is the code:
Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIdocument
Set uidoc=ws.currentDocument
Dim doc As NotesDocument
Set doc=uidoc.document
Const Saturday = 7
Const Sunday = 1
’ must have valid dates…
If doc.StartDate(0)="" Or doc.EndDate(0)="" Then
Exit Sub
End If
Dim count As Integer
count = 0 ' half days
Dim dtVacationDayStart As New NotesDateTime(doc.startdate(0) )
Dim dtVacationDayEnd As New NotesDateTime(doc.enddate(0) )
'Determine if the user has requested an end date before the start date
If dtVacationDayStart.TimeDifference(dtVacationDayEnd ) > 0 Then
Messagebox "you can't do that"
Exit Sub
Else
Dim strVacationDate As String
strVacationDate=dtVacationDayStart.DateOnly
Dim dtVacationDay As New NotesDateTime(strVacationDate )
Dim vacationdays As Integer
Dim itemHolidays As NotesItem
Set itemHolidays=doc.GetFirstItem("Holidays")
Dim w As Integer
While Not (dtVacationDay.dateOnly >dtVacationDayEnd.DateOnly)
If Not (Weekday(dtVacationDay.DateOnly)=Saturday Or Weekday(dtVacationDay.DateOnly)=Sunday) Then
If Not(ItemHolidays.Contains(dtVacationDay)) Then
count=count+2
End If
End If
Call dtVacationDay.AdjustDay(1)
Wend
’ adjust for half days…
If doc.HalfDay(0) <> "" Then count = count - 1
If doc.EndHalf(0) <> "" Then count = count - 1
doc.TotalDays2 = count / 2 ' display result
End If
Call uidoc.Refresh