Hi, this is my first visit to this site, so please bear with me while I get my feet wet.
I am attempting to use Excel VBA to read through documents in a Lotus Notes database. I found the following code on the web, and modified it with the database server name and directory. When I execute the code, I’m receiving a Run Time Error 91, Object variable or With block variable not se on the highlighted line of code. Any ideas? Or in lieu of ideas, does anyone have a code snippet that they know works?
Private Sub CommandButton1_Click()
Dim Ans, session, db, View, doc, i, strShtName, Value01, Value02
Ans = MsgBox(“Execute?”, vbYesNo, “Confirm”)
If Ans = vbNo Then Exit Sub
Set session = CreateObject(“Notes.NotesSession”)
'##### define Notes server and file path
Set db = session.GetDatabase(“CAMDB01/CAM/A/Lotus”, “d_dir\salesbomdb2.nsf”)
'##### get Notes view
Set View = db.GetView(“view01”)
i = 2
Set strShtName = ActiveSheet
Set doc = View.GetFirstDocument
Do Until doc Is Nothing
Value01 = doc.GetItemValue(“DB_Value01”)
Value02 = doc.GetItemValue(“DB_Value02”)
strShtName.Cells(i, 2) = Value01(0)
strShtName.Cells(i, 3) = Value02(0)
Set doc = View.GetNextDocument(doc)
i = i + 1
Loop
strShtName.Range(Cells(2, 1), Cells(i, 3)) _
.Sort Key1:=strShtName.Cells(1, 3), order1:=xlAscending, _
Key2:=strShtName.Cells(1, 2), order2:=xlAscending
MsgBox “Finished!”
End Sub