Could someone please help me translate this script into something that can be used in Excel VBA. I have a userform setup but the script doesn't like the code in this sub:
Thanks in advancePrivate Sub LookupNOTESAddressBook() Dim session As Object Dim db As Object Dim view As Object Dim vc As Object Dim entry As Object Dim items As Object Dim server As String Dim addressbookDB As String Dim intCount As Integer Dim intFound As Integer Try server = "CN=UK-MAIL-01/OU=SERVERS/O=NOTES" addressbookDB = "names.nsf" session = CreateObject("Notes.NotesSession") db = session.GETDATABASE(server, addressbookDB) view = db.GETVIEW("People") vc = view.GETALLENTRIESBYKEY(strSurname) entry = vc.GETFIRSTENTRY() intFound = vc.count ToolStripStatusLabel1.Text = "Found " & intFound & " matches..." Application.DoEvents() If intFound > 0 Then intCount = 0 Do While Not entry Is Nothing 'Increment count intCount = intCount + 1 'Pull all columnvalues from entry into ITEMS() array items = entry.COLUMNVALUES 'Add the value of the 7th item in the ITEMS array to the list box lstResults.Items.Add(items(6)) 'Move to the next entry entry = vc.GETNEXTENTRY(entry) Loop ToolStripStatusLabel1.Text = "Displaying " & intFound & " results" Else ToolStripStatusLabel1.Text = "No match found" End If Catch e As Exception MsgBox(e.Message, MsgBoxStyle.Information, "NOTES Addressbook Search") End Try vc = Nothing view = Nothing db = Nothing session = Nothing items = Nothing txtSurname.Enabled = True cmdSearch.Enabled = True cmdCancel.Enabled = True cmdOK.Enabled = True End Sub
Give this a whirl, that code looks like something someone wrote in VB6/Excel VBA then converted to .Net so it is fairly easy to convert back
This is a guess since I don't have lotus notes
Private Sub LookupNOTESAddressBook() Dim session As Object Dim db As Object Dim view As Object Dim vc As Object Dim entry As Object Dim items As Object Dim server As String Dim addressbookDB As String Dim intCount As Integer Dim intFound As Integer 'Try server = "CN=UK-MAIL-01/OU=SERVERS/O=NOTES" addressbookDB = "names.nsf" session = CreateObject("Notes.NotesSession") db = session.GETDATABASE(server, addressbookDB) view = db.GETVIEW("People") vc = view.GETALLENTRIESBYKEY(strSurname) entry = vc.GETFIRSTENTRY() intFound = vc.Count ToolStripStatusLabel1.Text = "Found " & intFound & " matches..." DoEvents If intFound > 0 Then intCount = 0 Do While Not entry Is Nothing 'Increment count intCount = intCount + 1 'Pull all columnvalues from entry into ITEMS() array items = entry.COLUMNVALUES 'Add the value of the 7th item in the ITEMS array to the list box lstResults.items.Add (items(6)) 'Move to the next entry entry = vc.GETNEXTENTRY(entry) Loop ToolStripStatusLabel1.Text = "Displaying " & intFound & " results" Else ToolStripStatusLabel1.Text = "No match found" End If 'Catch e As Exception ' MsgBox(e.Message, MsgBoxStyle.Information, "NOTES Addressbook Search") ' End Try vc = Nothing view = Nothing db = Nothing session = Nothing items = Nothing txtSurname.Enabled = True cmdSearch.Enabled = True cmdCancel.Enabled = True cmdOK.Enabled = True End Sub
Click the * below to say thanks
Girls sleep with guys who use photoshop, but marry the ones who work with Excel
Corduroy pillows: They're making headlines!
Did you mean: recursion
http://www.google.com/search?hl=en&q=recursion
Thanks for your reply. I ran the script but I receive an error:
"Run-time error 91: Object variable or With block variable not set"
The Debug highlights this line of code:
session = CreateObject("Notes.NotesSession")
Sorry, I forgot to set the objects, try the below:
Private Sub LookupNOTESAddressBook() Dim session As Object Dim db As Object Dim view As Object Dim vc As Object Dim entry As Object Dim items As Object Dim server As String Dim addressbookDB As String Dim intCount As Integer Dim intFound As Integer 'Try server = "CN=UK-MAIL-01/OU=SERVERS/O=NOTES" addressbookDB = "names.nsf" Set session = CreateObject("Notes.NotesSession") Set db = session.GETDATABASE(server, addressbookDB) Set view = db.GETVIEW("People") Set vc = view.GETALLENTRIESBYKEY(strSurname) Set entry = vc.GETFIRSTENTRY() intFound = vc.Count ToolStripStatusLabel1.Text = "Found " & intFound & " matches..." DoEvents If intFound > 0 Then intCount = 0 Do While Not entry Is Nothing 'Increment count intCount = intCount + 1 'Pull all columnvalues from entry into ITEMS() array Set items = entry.COLUMNVALUES 'Add the value of the 7th item in the ITEMS array to the list box lstResults.items.Add (items(6)) 'Move to the next entry Set entry = vc.GETNEXTENTRY(entry) Loop ToolStripStatusLabel1.Text = "Displaying " & intFound & " results" Else ToolStripStatusLabel1.Text = "No match found" End If 'Catch e As Exception ' MsgBox(e.Message, MsgBoxStyle.Information, "NOTES Addressbook Search") ' End Try Set vc = Nothing Set view = Nothing Set db = Nothing Set session = Nothing Set items = Nothing txtSurname.Enabled = True cmdSearch.Enabled = True cmdCancel.Enabled = True cmdOK.Enabled = True End Sub
Click the * below to say thanks
Girls sleep with guys who use photoshop, but marry the ones who work with Excel
Corduroy pillows: They're making headlines!
Did you mean: recursion
http://www.google.com/search?hl=en&q=recursion
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks