Hallo Leute,
in einer Datenbank besteht eine Script Library, natürlich in Script, genau das, was ich nicht kann.. Dieses Script ist für ein Button bestimmt, der den Urlaubsantrag in den lokalen Notes Kalender einträgt.. Das funktioniert aber nicht bei allen..
Kann jemand von euch mal bitte drüber schauen und mir evtl. den Fehler verbessern? Wäre super nett...
Code
Sub AddCalendarEntry 'modiefied by xx 02.11.2005
Dim session As New NotesSession
Dim locationdoc As notesdocument
Dim locationview As notesview
Dim Location As String
Dim NAB As New NotesDatabase("", "")
Dim MAILDB As New NotesDatabase("", "")
Dim Mail_Server As String, Mail_file As String
Dim ServerName As NotesName
If Messagebox("This will add Vacation record to your personal Calendar. Would you like to proceed?", 36, "Question") = 7 Then
Exit Sub
End If
If Not NAB.Open("", "NAMES.NSF") Then
Messagebox "Personal Address Book (names.nsf) does not found", 16, "Lotus Notes"
Exit Sub
End If
location = session.GetEnvironmentString("Location",True)
commaloc% = Instr(location, ",") ' find location of , in string ' the location in the view is identified by the part to the left of the comma
If commaloc% <> 0 Then ' if @ found and length < 8_@_8
'--- JF 12-30-97 - Removed Trim, caused problem with entries with double spaces
location = Left(location, commaloc% - 1) ' set value to string left of
End If
Set locationview = NAB.GetView("Locations")
Set locationdoc = locationview.GetDocumentByKey(location)
If locationdoc Is Nothing Then
Messagebox "Location document for current location ("+location+") was not found in your Personal Address Book (names.nsf)", 16, "Lotus Notes"
Exit Sub
End If
If Cstr(Locationdoc.MailType(0)) = "0" Then
Set ServerName = New NotesName( Locationdoc.MailServer(0))
Mail_Server = Cstr(ServerName.Abbreviated)
Mail_File = session.GetEnvironmentString("MailFile",True)
End If
If Cstr(Locationdoc.MailType(0)) = "1" Then
' Mail file is located on local mashine
Mail_Server = ""
Mail_File = session.GetEnvironmentString("MailFile",True)
commaloc% = Instr(Mail_File, "\")
While commaloc% <> 0
Mail_File = Right(Mail_File, Len(Mail_File)-commaloc%)
commaloc% = Instr(Mail_File, "\")
Wend
End If
If Not MAILDB.Open(Mail_Server, Mail_File) Then
If Mail_Server = "" Then
Messagebox "Your mail file ("+Mail_File+") was not found, on local mashine", 16, "Lotus Notes"
Else
Messagebox "Your mail file ("+Mail_File+") was not found, on server "+Mail_Server, 16, "Lotus Notes"
End If
Exit Sub
End If
Dim EventDoc As notesdocument
Dim ws As New notesUIworkspace
Dim doc_Item As notesitem
Dim doc As notesdocument
Dim rtitem As NotesRichTextItem
Dim success As Variant
Dim stime As String
Dim etime As String
Dim exview ( 1 To 2 ) As String
exview(1) = "D"
exview(2) = "S"
' Dim edoc_item As notesitem
stime = "09:00:00"
etime = "20:00:00"
Set doc = ws.currentdocument.document
Set EventDoc = New NotesDocument(MAILDB)
'general Calendar Document Properties
EventDoc.Form = "Appointment"
EventDoc.AppointmentType = "2"
EventDoc.ExcludeFromView = exview
EventDoc.MeetingType = "1"
EventDoc.OrgTable = "P0"
EventDoc.Chair = doc.EmployeeName(0)
EventDoc.Logo = "stdNotesLtr0"
Call EventDoc.ReplaceItemValue("$PublicAccess","1")
EventDoc.Subject = "V: Urlaub von "+doc.EmployeeNameDisplay(0)+Chr(13)+" vom "+Cstr(doc.VacStartDate(0))+" bis "+Cstr(doc.VacEndDate(0))+Chr(13)+"Vertretung: "+doc.StandInT(0)
Call EventDoc.ReplaceItemValue( "_ViewIcon", 9 )
'---------------------------------------------------------------
'Start & End Date/Time Values
Set Doc_item = doc.GetFirstItem( "VacStartDate" )
EventDoc.StartDateTime = Cdat(doc.StartDate(0) + stime)
Call EventDoc.CopyItem( doc_item, "StartDate")
EventDoc.StartTime = Timevalue(stime)
Set Doc_item = doc.GetFirstItem ( "AllVacDays" )
Call EventDoc.CopyItem( doc_item, "CalendarDateTime" )
Set Doc_item = doc.GetFirstItem( "VacEndDate" )
EventDoc.EndDateTime = Cdat(doc.EndDate(0) + etime)
Call EventDoc.CopyItem( doc_item, "EndDate" )
EventDoc.EndTime = Timevalue(etime)
'--------------------------------------------------------------------------
Set rtitem = New NotesRichTextItem( EventDoc, "Body" )
success = doc.RenderToRTItem( rtitem )
Call EventDoc.save(True, True)
Messagebox "This vacation record was successfully added to your personal Calendar", 64, "Operation completed successfully"
End Sub
Alles anzeigen
Danke.