Compose and save a document by agent

I have to create and save a document, a report, every day after 5 pm.The document is “IT Overview Report”.I am trying to do this by a scheduled agent.The code I am writing is :

Sub Click(Source As Button)

Dim w As New NotesUIWorkspace

Dim session As New NotesSession	

Dim db As NotesDatabase

Dim uidoc As NotesUIDocument

Dim doc1 As NotesDocument

Dim doc As NotesDocument	



Set db = session.CurrentDatabase	

Set doc1 = db.CreateDocument



Set doc = Call w.ComposeDocument( "", "", "IT Overview Report" )



Call uidoc.Save

unid = doc.UniversalID

doc.SaveOptions = "0"



Call doc.Save(False, True)	

Call uidoc.close

End Sub

I have got the error on

    Set doc = Call w.ComposeDocument( "", "", "IT Overview Report" )

Why it is so?what mistake i am doing?

Thanks.

Subject: compose and save a document by agent

Hi Aisha ,

You cannot run UI Classes on a schedule agent .

Remove the lines of code where UI classes have been used, eg as NotesUIWorkspace

use db.createdocument method to create forms on the fly … see example below.

Set doc = db.CreateDocument

doc.Form = “IT Overview Report”

doc.EmpName = …

doc.EmpID=…

call doc.save (True, False)

This will work …

Siddhartha.

Subject: RE: compose and save a document by agent

Thanks Siddhartha,

Its working. :slight_smile:

Subject: UI & Backend Classes => Designer Help 1st step… :cry: