Agent to write documents in a View to text file

Hi I am trying to write documents in a view to a text file My small piece of code is shown below. Please bare in mind im new to LotusScript and theres probably a few holes you can see with it:

Sub Click(Source As Button)

On Error Resume Next



Dim session As NotesSession

Dim db As NotesDatabase

Dim view As NotesView



Set session = New NotesSession

Set db = session.CurrentDatabase

Set view = db.GetView("People (other)\Certificate Expiration")

Set doc = view.GetFirstDocument()



strOut = "Begin Processing" &Chr(13) & Chr(10)



While Not (doc Is Nothing)

	

	Error.clear

	

	Set nextdoc = view.GetNextDocument(doc)

	strUser = doc.GetItemValue(0)		

	strOut = strOut & "Processing " & strUser & Chr(13) & Chr(10)

	

	If Err <> 0 Then

		strOut = strOut & "--> ERROR: " & Error$ & Chr(13) & Chr(10)

	End If

	

	Set doc = nextdoc

	

Wend



intHandle = Freefile

Open "D:\Data\NotesRecertification.txt" For Output As #intHandle

Print #intHandle, strOut

Close #intHandle

Msgbox "Finished"

End Sub

The code creates the text file fine however all documents are replaced with the same error message “Type mismatch”

Can anyone see where ive went wrong

Thanks for the help.

Subject: Agent to write documents in a View to text file

Use declaration:

dim strUser as string, strOut as string

and change line:

strUser = doc.GetItemValue(0)

to:

strUser = doc.GetItemValue(“fieldName”)(0)

Konrad

Subject: RE: Agent to write documents in a View to text file

Thanks for the help Konrad…I’m now getting"Named product object does not exist" which looks like its saying the field I entered doesnt exist but it definatly does

An example line:

"Processing Ball

→ ERROR: Named product object does not exist"

So it is given me the persons name however the error should not exist…should it?

Subject: RE: Agent to write documents in a View to text file

Error.clear is incorrect statement.

Use Err = 0 instead.

Konrad

Subject: RE: Agent to write documents in a View to text file

Thankyou very much! works perfect.