| Public Function NotesKalenderEinlesen(strServer As String, strMailDB As String, datStart As Date, datEnde As Date) As Integer |
| |
| Dim objNotes As Object |
| Dim LNdb As Object |
| Dim LNView As Object |
| Dim DateTimeStart As Object |
| Dim DateTimeEnd As Object |
| Dim DateRange As Object |
| Dim Collection As Object |
| Dim LNDoc As Object |
| Dim LNItem As Object |
| Dim datDatetime As Date |
| Dim rsTermine As DAO.Recordset |
| Dim rsFehler As DAO.Recordset |
| Dim strCalDateTime() As String |
| Dim strEndDateTime() As String |
| Dim i As Integer |
| Dim intAnzahl As Integer |
| |
| |
| On Error GoTo ErrBeh |
| |
| |
| CurrentDb.Execute "DELETE tblTermine.* FROM tblTermine" |
| |
| Set rsTermine = CurrentDb.OpenRecordset("tblTermine", dbOpenTable) |
| |
| |
| Set objNotes = GetObject("", "Notes.NotesSession") |
| |
| Set LNdb = objNotes.GETDATABASE(strServer, strMailDB, False) |
| |
| If Not (LNdb Is Nothing) Then |
| |
| |
| Set LNView = LNdb.GETVIEW("Calendar") |
| |
| If LNView Is Nothing = False Then |
| |
| |
| Set DateTimeStart = objNotes.CreateDateTime(Day(datStart) & "." & Month(datStart) & "." & Year(datStart)) |
| Set DateTimeEnd = objNotes.CreateDateTime(Day(datEnde) & "." & Month(datEnde) & "." & Year(datEnde)) |
| Set DateRange = objNotes.CreateDateRange |
| Set DateRange.StartDateTime = DateTimeStart |
| Set DateRange.ENDDATETIME = DateTimeEnd |
| |
| |
| Set Collection = LNView.GETALLDOCUMENTSBYKEY(DateRange) |
| |
| |
| Set LNDoc = Collection.GETFIRSTDOCUMENT |
| |
| Do While Not LNDoc Is Nothing |
| |
| |
| Set LNItem = LNDoc.GETFIRSTITEM("CalendarDateTime") |
| strCalDateTime = Split(LNItem.Text, ";") |
| |
| If UBound(strCalDateTime) = 0 Then |
| intAnzahl = 0 |
| Else |
| intAnzahl = UBound(strCalDateTime) - 1 |
| End If |
| |
| For i = 0 To intAnzahl |
| |
| datDatetime = CDate(strCalDateTime(i)) |
| If DateSerial(Year(datDatetime), Month(datDatetime), Day(datDatetime)) >= datStart And _ |
| DateSerial(Year(datDatetime), Month(datDatetime), Day(datDatetime)) <= datEnde Then |
| |
| rsTermine.AddNew |
| |
| |
| rsTermine.Fields("Start_Datum").Value = DateSerial(Year(datDatetime), Month(datDatetime), Day(datDatetime)) |
| rsTermine.Fields("Start_Uhrzeit").Value = TimeSerial(Hour(datDatetime), Minute(datDatetime), Second(datDatetime)) |
| |
| |
| Set LNItem = LNDoc.GETFIRSTITEM("EndDateTime") |
| strEndDateTime = Split(LNItem.Text, ";") |
| datDatetime = CDate(strEndDateTime(i)) |
| rsTermine.Fields("Ende_Datum").Value = DateSerial(Year(datDatetime), Month(datDatetime), Day(datDatetime)) |
| rsTermine.Fields("Ende_Uhrzeit").Value = TimeSerial(Hour(datDatetime), Minute(datDatetime), Second(datDatetime)) |
| |
| |
| Set LNItem = LNDoc.GETFIRSTITEM("Subject") |
| If LNItem Is Nothing = False Then |
| rsTermine.Fields("Terminbezeichnung").Value = LNItem.Text |
| End If |
| |
| |
| Set LNItem = LNDoc.GETFIRSTITEM("Body") |
| If LNItem Is Nothing = False Then |
| rsTermine.Fields("Termindetails").Value = LNItem.Text |
| End If |
| |
| |
| Set LNItem = LNDoc.GETFIRSTITEM("Location") |
| If LNItem Is Nothing = False Then |
| rsTermine.Fields("Ort").Value = LNItem.Text |
| End If |
| |
| rsTermine.Update |
| |
| End If |
| |
| Next |
| |
| |
| Set LNDoc = Collection.GETNEXTDOCUMENT(LNDoc) |
| |
| DoEvents |
| |
| Loop |
| End If |
| End If |
| |
| GoTo Ende |
| |
| ErrBeh: |
| Set rsFehler = CurrentDb.OpenRecordset("tblFehler", dbOpenTable) |
| rsFehler.AddNew |
| rsFehler.Fields(0).Value = 0 |
| rsFehler.Fields(1).Value = Err.Description |
| rsFehler.Update |
| rsFehler.Close |
| Set rsFehler = Nothing |
| Err.Clear |
| Resume Next |
| |
| Ende: |
| Set objNotes = Nothing |
| Set LNdb = Nothing |
| Set LNView = Nothing |
| Set LNItem = Nothing |
| Set LNDoc = Nothing |
| |
| End Function |