UnprocessedDocuments Error

I am trying to create an action button that will run on selected documents in a view. However, I can’t get it to set the unprocessed documents - I keep getting an error that says “Variant does not contain an object”. Here is the beginning of the script - according to the debugger, the error throws on the setting of the document collection.

What am I missing?

Dim ses As New NotesSession

Dim srdb As NotesDatabase

Dim ptodb As NotesDatabase

Dim openview As NotesView

Dim mihdview As NotesView

Dim ptoview As NotesView

Dim adcol As NotesDocumentCollection

Dim addoc As NotesDocument

Dim empdoc As NotesDocument

Dim ptodoc As NotesDocument

Dim srdc As NotesDocumentCollection

Dim emplist(30) As String



Set srdb = ses.CurrentDatabase

Set ptodb = ses.GetDatabase ("", "sdnhslkup.nsf")



Set adcol = srdb.UnprocessedDocuments

Set addoc = addc.GetFirstDocument()

Subject: UnprocessedDocuments Error

Looks like you’re using two separate names for your collection, “adcol” and “addc”. Do you have “Option Declare” turned on?

Subject: RE: UnprocessedDocuments Error

Okay … fixed that, but it’s still erroring out before that - when I try to set the document collection. Here’s the new code.

I’m a fairly new scripter … What is “Options Declare”?

Dim ses As New NotesSession

Dim srdb As NotesDatabase

Dim ptodb As NotesDatabase

Dim openview As NotesView

Dim mihdview As NotesView

Dim ptoview As NotesView

Dim adcol As NotesDocumentCollection

Dim addoc As NotesDocument

Dim empdoc As NotesDocument

Dim ptodoc As NotesDocument

Dim srdc As NotesDocumentCollection

Dim emplist(30) As String



Set srdb = ses.CurrentDatabase

Set ptodb = ses.GetDatabase ("", "sdnhslkup.nsf")



Set adcol = srdb.UnprocessedDocuments

Set addoc = adcol.GetFirstDocument()

Subject: RE: UnprocessedDocuments Error

It’s “Option Declare” actually (not Options). It goes in the “(Options)” section of the script code. It forces you to have a “Dim” statement for every variable. The advantage is that it catches you if you have a typo and reference a variable that doesn’t match what you Dim’ed.

You can turn it on automatically in your Designer under “Programmer Pane Properties”.

Subject: UnprocessedDocuments Error

nevermind…