Hallo zusammen,
ich möchte meine Termine aus Notes in eine Access DB importieren.
Dazu habe ich folgendes programmiert:
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
On Error GoTo ErrBeh
'tblTermine leeren
CurrentDb.Execute "DELETE tblTermine.* FROM tblTermine"
Set rsTermine = CurrentDb.OpenRecordset("tblTermine", dbOpenTable)
'Holen einer aktiven Notessession
Set objNotes = GetObject("", "Notes.NotesSession")
'Verweisen auf die gewünschte Datenbank
Set LNdb = objNotes.GETDATABASE(strServer, strMailDB)
If Not (LNdb Is Nothing) Then
Set LNView = LNdb.GETVIEW("$Calendar")
If LNView Is Nothing = False Then
'Zeitraum setzen
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
'Collection füllen
Set Collection = LNView.GETALLDOCUMENTSBYKEY(DateRange)
'Einlesen des ersten Mail-Dokuments
Set LNDoc = Collection.GETFIRSTDOCUMENT
Do While Not LNDoc Is Nothing
rsTermine.AddNew
'Start
Set LNItem = LNDoc.GETFIRSTITEM("StartDate")
If LNItem Is Nothing = False Then
datDatetime = CDate(LNItem.Text)
rsTermine.Fields("Start_Datum").Value = DateSerial(Year(datDatetime), Month(datDatetime), Day(datDatetime))
End If
Set LNItem = LNDoc.GETFIRSTITEM("StartTime")
If LNItem Is Nothing = False Then
datDatetime = CDate(LNItem.Text)
rsTermine.Fields("Start_Uhrzeit").Value = TimeSerial(Hour(datDatetime), Minute(datDatetime), Second(datDatetime))
End If
'Ende
Set LNItem = LNDoc.GETFIRSTITEM("EndDate")
If LNItem Is Nothing = False Then
datDatetime = CDate(LNItem.Text)
rsTermine.Fields("Ende_Datum").Value = DateSerial(Year(datDatetime), Month(datDatetime), Day(datDatetime))
End If
Set LNItem = LNDoc.GETFIRSTITEM("EndTime")
If LNItem Is Nothing = False Then
datDatetime = CDate(LNItem.Text)
rsTermine.Fields("Ende_Uhrzeit").Value = TimeSerial(Hour(datDatetime), Minute(datDatetime), Second(datDatetime))
End If
'Terminbezeichnung
Set LNItem = LNDoc.GETFIRSTITEM("Subject")
If LNItem Is Nothing = False Then
rsTermine.Fields("Terminbezeichnung").Value = LNItem.Text
End If
'Termindetails
Set LNItem = LNDoc.GETFIRSTITEM("Body")
If LNItem Is Nothing = False Then
rsTermine.Fields("Termindetails").Value = LNItem.Text
End If
'Ort
Set LNItem = LNDoc.GETFIRSTITEM("Location")
If LNItem Is Nothing = False Then
rsTermine.Fields("Ort").Value = LNItem.Text
End If
rsTermine.Update
'Ermitteln des nächsten Mail-Dokuments
Set LNDoc = Collection.GETNEXTDOCUMENT(LNDoc)
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
Leider werden nicht alle Termine importiert.
Meine Vermutung ist dass verschobene Termine, Serientermine & Termine die vor dem Anfragezeitraum erstellt wurden in der Anzeige fehlen.
Hat jemand eine Idee wie ich alle meine Termine im gewünschten Zeitraum einlesen kann?
Grüße
Eric