Object Variable not set in @GetDocumentByKey

Hi

I have Leave Database in the development server. Once leave is approved, mail goes to the user, saying his/her leave is approved. We wanted to enhance it further to include the leave in user’s Calender. However I have some problem with the code. Along with the mail, I have attached a button to the user clicking which would add the calender. linkDoc is not getting set. When the point comes to Messagebox … it says “Object Variable not set”. I tried to make ($All) as the default view of the db and tried to use GETDOCUMENTBYUNID, for which it says Invalid Universal id.

Below is the code,

    Dim ws As New NotesUIWorkspace

Dim session As New NotesSession	

Dim db As New NotesDatabase("x","x")

Dim view As NotesView

Dim uidoc As NotesUIDocument

Dim doc As NotesDocument

Dim curdoc As NotesUIDocument

Dim ndoc As NotesDocument

Dim rti As NotesRichTextItem

Dim rtnav As NotesRichTextNavigator

Dim rtlink As NotesRichTextDocLink

Dim linkDoc As NotesDocument



Set view = db.GetView ("($All)")

Set curdoc = ws.CurrentDocument

Set ndoc = curdoc.Document

Set rti = ndoc.GetFirstItem("Body")

Set rtnav = rti.CreateNavigator



Set rtlink= rtnav.GetFirstElement(RTELEM_TYPE_DOCLINK)

Messagebox rtlink.DocUnID

	

Set linkDoc = db.GetDocumentByUNID(rtlink.DocUNID)



     Messagebox linkDoc.GetItemValue("Leave_Type")(0)

Call ws.ComposeDocument("","","Appointment")

Set uidoc =ws.CurrentDocument

Call uidoc.FieldSetText("AppointmentType", "0")

Call uidoc.FieldSetText("Subject",linkDoc.GetItemValue("Leave_Type") (0))

Call uidoc.Save()

Call uidoc.Close

Can somebody help me.

Raji

Subject: Object Variable not set in @GetDocumentByKey

Messagebox rtlink.DocUnID(0)

Subject: RE: Object Variable not set in @GetDocumentByKey

It says illegal paranthesized reference.

Subject: RE: Object Variable not set in @GetDocumentByKey

Messagebox doc.UniversalID