Option Public
Option Declare
Sub Initialize
'If all Readers fields are blank, anyone can read the document.
'If there are multiple Readers fields and some are blank, the non-blank fields limit access.
Dim sn As New NotesSession
Dim db As NotesDatabase
Dim dbCur As NotesDatabase
Dim doccol As NotesDocumentCollection
Dim doc As NotesDocument
Dim lngCnt As Integer
On Error 4060 GoTo NoDbAccess 'lsERR_NOTES_DBNOACCESS
On Error GoTo ErrorHandler
Set dbCur = sn.Currentdatabase
Set db = sn.GetDatabase("Server/Name", "filepath\filename.nsf") 'Results in error 4060 if No Access --> db Is Nothing
If Not db Is Nothing Then
If db.IsOpen Then
Set doccol = db.Alldocuments
If doccol.Count > 0 Then
Set doc = doccol.GetFirstDocument
While Not doc Is Nothing
ForAll itm In doc.Items
If itm.Isreaders Then
If itm.Text <> "" Then
'Reader field found
Print "reader field found"
GoTo NextDoc
End If
End If
End ForAll
NextDoc:
Set doc = doccol.GetNextDocument(doc)
Wend
End If
Else
Print "DB DOES NOT EXIST"
End If
Else
Print "NO ACCESS"
End If
Exit Sub
NoDbAccess:
'Error 4060
Print "no access to database " & db.Filepath & " - resuming next database..."
Resume Next
Exit Sub
ErrorHandler:
Print "Error..."
Exit Sub
End Sub