Skip to content

Instantly share code, notes, and snippets.

@mjsqu
Last active September 9, 2019 03:14
Show Gist options
  • Save mjsqu/4d2bfc8628752d288e50cc08ca03ba14 to your computer and use it in GitHub Desktop.
Save mjsqu/4d2bfc8628752d288e50cc08ca03ba14 to your computer and use it in GitHub Desktop.
Gets Lotus Notes NotesDocument information from a NotesDatabase
' Requires that LotusNotes Item/Field names are entered across the first row in a sheet
' E.g. Try adding Title, Status, Initiator on the first row
' Fills out values based on criteria entered in "SearchString" - currently set to "Author is me"
Sub GetDocProps()
Set Session = CreateObject("Lotus.NotesSession") 'Start a session to notes
strPass = ""
Call Session.Initialize(strPass)
strSrv = ""
strDb = ""
Set Db = Session.GETDATABASE(strSrv, strDb)
' Get this string by right clicking in a document form once it is opened
SearchString = "@Contains(@Author;" & Chr(34) & Application.UserName & Chr(34) & ")"
Set dtime = Session.CREATEDATETIME("01/08/2019 00:00:01 AM")
Set Docs = Db.Search(SearchString, dtime, 0)
Set Doc = Docs.GETFIRSTDOCUMENT
C = 0
Set HeaderRange = Range(Range("A1"), Range("A1").End(xlToRight))
Set ClearRange = Range("A2", "AZ20000")
ClearRange.ClearContents
While Not (Doc Is Nothing)
ColNum = 0
' Get item names from across the top row
For Each ItemName In HeaderRange.Cells
Debug.Print (ItemName)
V = Doc.GETITEMVALUE(ItemName)
For Each Value In V
Sheets("Sheet1").Range("A2").Offset(RowNum, ColNum) = Value
ColNum = ColNum + 1
Next
'Tack the NotesURL on the end
Sheets("Sheet1").Range("A2").Offset(RowNum, ColNum) = Doc.NOTESURL
Next
Set Doc = Docs.GETNEXTDOCUMENT(Doc)
RowNum = RowNum + 1
Wend
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment