Need to write a script

that will start at the top of a view, open the document, run the postopen script, save and close the document.

I’ve tried all sorts of stuff but I can’t get it to work…

any suggestions? I’ve done the document collection thing and tried to edit, but it just doesn’t work.

here’s the code I’ve written:

Sub Click(Source As Button)

Dim session As New NotesSession

Dim db As NotesDatabase

Dim workspace As New NotesUIWorkspace

Dim collection As NotesDocumentCollection

Dim doc As NotesDocument

Dim uiview As NotesUIView

Set db = session.CurrentDatabase

Set uiview = workspace.CurrentView

searchformula$={atttype="Other"}

Set collection = db.search(searchformula$,Nothing,0)

'Set collection = db.search

Set doc = collection.GetFirstDocument

Call uiview.SelectDocument(doc)

uname=doc.GetItemValue("PeFullName")

'Call workspace.editdocument(True

Do While Not (doc Is Nothing)

	Call workspace.editdocument(True)

	Set doc=collection.GetNextDocument(doc)

	uname=doc.getitemvalue("peFullName")

	

Loop

End Sub

Subject: Need to write a script…

Suzanne -

Why not just write an agent that will run on selected or all document in a view. In this agent, put your PostOpen event scriptin it? Just an idea.

Mike

Subject: RE: Need to write a script…

I would love to, but some of the code in the postopen will not run in an agent. I tried it.

it gives me an error message (it’s a script in the script library that takes an object and save it into word format and saves the file to my hard drive).

Dim sReturn$



sReturn$ = gpProcessOLEObjectUI("SaveAs")

The script it’s running is a function in the scriptlibrary. If I try to put this in to an agent, it stops on the second line (sReturn$) and returns an error message in an agent. Run from a button on the form, it’s fine.

Subject: RE: Need to write a script…

U should not need the uiview

Do While Not (doc Is Nothing)

uname=doc.GetItemValue(“PeFullName”)

Set UIDoc = workspace.editdocument(True, doc) >> Check the correct syntax to open there should be atleast 2 parms

UIdoc.close

Set doc=collection.GetNextDocument(doc)

Loop