Trouble saving LS created calendar entry

All,

I have script that creates an appointment on a calendar. It will fill in the start date, end date, and subject.

If I place the doc in edit mode, save and close. Then the entry is in my calendar (I have remmed out ’ that code below). If I Call doc.Save(True,True) without placing the entry in edit mode, the entry does not save. I have refreshed my calendar view to see if it is just a refresh issue but it was not there.

Here is my code:

Dim NotesSession As New NotesSession

Dim workspace As New NotesUIWorkspace

Dim Doc As NotesDocument

Dim db As NotesDatabase

Dim UIDoc As NotesUIDocument  

Dim CurDoc As NotesDocument

Set CurDoc = workspace.CurrentDocument.Document



Set db = NotesSession.GetDatabase("Edison/SEL",CurDoc.Calendar(0))

Set doc = db.CreateDocument

doc.form = "Appointment"

sd =CurDoc.SDate(0) 

ed =CurDoc.EDate(0) 

st =CurDoc.SDate_1(0) 

et =CurDoc.EDate_1(0) 

Set itemA = doc.ReplaceItemValue("Subject", "**APPROVED LEAVE**")

Set itemA = doc.ReplaceItemValue("Broadcast", "1")

Set itemA = doc.ReplaceItemValue("AppointmentType", "2")  

Set itemA = doc.ReplaceItemValue("Alarms", "0")  

Set itemA = doc.ReplaceItemValue("StartDateTime", Cdat(st))  

Set itemA = doc.ReplaceItemValue("EndDateTime", Cdat(et))  

Set itemA = doc.ReplaceItemValue("StartDate", Cdat(sd))  

Set itemA = doc.ReplaceItemValue("EndDate", Cdat(ed))  



doc.ExcludeFromView = "D"

’ Set UIDoc = Workspace.EditDocument(True,doc)

’ Call UIDoc.Save

’ Call UIDoc.Close

Call doc.ComputeWithForm(False,False)

Call doc.Save(True,True)	

At present this is in a button action, but I will eventually move it to an agent to run on the server so that the entry can be added to another’s calendar.

Thanks for any help,

Teri