Domino 9 und frühere Versionen > Entwicklung

Objektvariable not Set

(1/4) > >>

Thunder:
Hallo,

kleines Scriptproblem:
Ich habe dieses Script aus einem Forum entnommen (funzt auch ganz gut) und wollte es etwas erweitern.Leider läuft das nicht so ganz, wie ich mir das gedacht habe-ist aber bestimmt nur eine Kleinigkeit.
Das Script schreibt einfach nur Einträge in den aktuellen Kalender.
Ich habe eine Maske, womit man Urlaub, Gleittage, sonstige Abwesenheiten beantragen kann. Diese möchte ich in den Kalender übernehmen. Es gibt also 3x die Felder VOM - BIS mit natürlich anderer Bezeichnung.Ich dachte mir also - kopiere das Script noch einmal drunter, ändere es etwas ab und alles ist gut. Er wirft mir aber leider den Fehler ' Objektvariable not Set' raus. Was muß ich noch definieren ?

Sub Click(Source As Button)
     Dim Session As New NotesSession
     Dim Workspace As New NotesUIWorkspace
     Dim TheDocument As NotesDocument
     Dim db As notesDatabase
     Dim UserName As String
     
     Set UIDoc = Workspace.CurrentDocument
     Set TheDocument = UIDoc.Document
     
     Set db = New NotesDatabase("", "")
' Open user's mail database
     db.openmail
     
' Notestime variabels
     Dim StartDatum As String
     Dim EindDatum As String
     

' Urlaub ------------------------------------------------------------

' Get variabels from document
     StartDatum = Uidoc.FieldGetText("gA_vom_1")
     EindDatum = Uidoc.FieldGetText("gA_bis_1")
     
     
'Conversion for string to datefield
     Set datum1 = New NotesDateTime (StartDatum)
     Set datum2 = New NotesDateTime (EindDatum)
     Call datum2.AdjustDay( 1 )
     
     Startdatum = Cstr(datum1.DateOnly)
     Einddatum = Cstr(datum2.DateOnly)
     
'The do while places the calendar item everyday unit startdate and endate are the same.
     Do While StartDatum <> EindDatum
         
'Call calender
          Dim CalendarEntry As New NotesDocument(db)
          Dim rtitem As New NotesRichTextItem(CalendarEntry, "Body")
          Call rtitem.AppendText("Voor details bekijk bijgesloten verlof verzoek")
          Call rtitem.AddNewline(1)
          Call rtitem.AppendDocLink(TheDocument, "Verlof")
          UserName = Session.CommonUserName
         
          CalendarEntry.Form = "Appointment"
          CalendarEntry.Principal = UserName
         
          CalendarEntry.Chair = Session.UserName
          CalendarEntry.ExcludeFromView = "D"
          CalendarEntry.OrgTable = "CO"
          CalendarEntry.SequenceNum = 1
          CalendarEntry.Subject = "Urlaub (Zina)"
         
         
'Appointment Type 4 = Reminder , 3 = meeting, 2 = event, 1 = anniversary, 0 = Personal
'Place string in calender fields
          CalendarEntry.AppointmentType = "4"
          CalendarEntry.StartDate = Cdat(StartDatum)
          CalendarEntry.StartDateTime = Cdat(StartDatum)
          CalendarEntry.CalendarDateTime = Cdat(StartDatum)
          CalendarEntry.EndDateTime = Cdat(StartDatum)
         
          Call CalendarEntry.save(True, True)
          Call datum1.AdjustDay( 1 )
          Startdatum = Cstr(datum1.DateOnly)
          Einddatum = Cstr(datum2.DateOnly)
     Loop
     
' Gleittage  -----------------------------------------------------------------------------------------
     
     
' Get variabels from document
     StartDatum = Uidoc.FieldGetText("gA_vom_4")
     EindDatum = Uidoc.FieldGetText("gA_bis_4")
     
     
'Conversion for string to datefield
     Set datum1 = New NotesDateTime (StartDatum)
     Set datum2 = New NotesDateTime (EindDatum)
     Call datum2.AdjustDay( 1 )
     
     Startdatum = Cstr(datum1.DateOnly)
     Einddatum = Cstr(datum2.DateOnly)
     
'The do while places the calendar item everyday unit startdate and endate are the same.
     Do While StartDatum <> EindDatum
         
'Call calender
          Call rtitem.AppendText("Voor details bekijk bijgesloten verlof verzoek")
          Call rtitem.AddNewline(1)
          Call rtitem.AppendDocLink(TheDocument, "Verlof")
          UserName = Session.CommonUserName
         
          CalendarEntry.Form = "Appointment"
          CalendarEntry.Principal = UserName
         
          CalendarEntry.Chair = Session.UserName
          CalendarEntry.ExcludeFromView = "D"
          CalendarEntry.OrgTable = "CO"
          CalendarEntry.SequenceNum = 1
          CalendarEntry.Subject = "Gleittage (Zina)"
         
         
'Appointment Type 4 = Reminder , 3 = meeting, 2 = event, 1 = anniversary, 0 = Personal
'Place string in calender fields
          CalendarEntry.AppointmentType = "4"
          CalendarEntry.StartDate = Cdat(StartDatum)
          CalendarEntry.StartDateTime = Cdat(StartDatum)
          CalendarEntry.CalendarDateTime = Cdat(StartDatum)
          CalendarEntry.EndDateTime = Cdat(StartDatum)
         
          Call CalendarEntry.save(True, True)
          Call datum1.AdjustDay( 1 )
          Startdatum = Cstr(datum1.DateOnly)
          Einddatum = Cstr(datum2.DateOnly)
     Loop
     
End Sub

koehlerbv:
Was sagt der Debugger ?

g202e:
Wie wär's mit SESSION?

koehlerbv:
Was soll mit Session sein ?

Thunder:
Das Script funzt wiegesagt bis zu den Gleittagen.
Wenn ich die Geschichte durch den Debugger laufen lasse
läuft er genau zu der Zeile -
    Call rtitem.AppendText("Voor details bekijk bijgesloten verlof verzoek")
im Gleittage-Abschnitt und sagt "Objekt variable not Set "
gruselig

Navigation

[0] Themen-Index

[#] Nächste Seite

Zur normalen Ansicht wechseln