473,385 Members | 1,769 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

lotus notes automation to Access using VBA

Hi all

I'm trying to set up an Access database that will be able to import
contact information from the lotus notes 6.5 Address book. The idea is
that the code runs from access to import all of the contacts, using
COM.

I've written the following vba code so far to import the contacts
'Set up DAO (Data Access Objects) using an object called RecordSet to
hold table
Dim TempContactRST As DAO.Recordset
'Use existing "Temporary Contact Details" table
Set TempContactRST = CurrentDb.OpenRecordset("Temporary Contact
Details")
'Set up objects required for automation into lotus notes
Dim Session As Object
Dim NotesDB As Object
Dim NotesView As Object
Dim NotesViewNav As Object
Dim NotesEntry As Object
Dim NotesDoc As Object
Dim Handle As Integer
Dim UserName As String
'Start a session to notes
Set Session = CreateObject("Notes.NotesSession")
'Open Address Book database
Set NotesDB = Session.GetDatabase("", "names.nsf")
If NotesDB.IsOpen = True Then
'Do nothing
Else
NotesDB.OPENMAIL
End If
Set NotesView = NotesDB.GetView("Contacts")
Set NotesViewNav = NotesView.CreateViewNav()
Set NotesEntry = NotesViewNav.GetFirstDocument()
While Not (NotesEntry Is Nothing)
Set NotesDoc = NotesEntry.Document
fname = NotesDoc.GetFirstItem("FirstName").Values
lname = NotesDoc.GetFirstItem("LastName").Values
JobTitle = NotesDoc.GetFirstItem("JobTitle").Values
CompanyName = NotesDoc.GetFirstItem("CompanyName").Values
TempContactRST.AddNew
TempContactRST!FirstName = fname(0)
TempContactRST!LastName = lname(0)
TempContactRST!Company = CompanyName(0)
TempContactRST!JobTitle = JobTitle(0)
TempContactRST.Update
Set NotesEntry = NotesViewNav.GetNextDocument(NotesEntry)
Wend
TempContactRST.Close
MsgBox "Finished"
Set Session = Nothing
Set NotesDB = Nothing
The problem i'm having is that because the address book isn't stored as

a relational database format then if one of the fields in the notes
address book has not had data added to it, the field name doesn't exist

in the document. This means that when the vba code tries to access a
field in the notes address book that has no data, the field name doesnt

exist and vba crashes, giving me a run time error 91 - Object variable
or With block variable not set.
Does anyone know a way around this problem? The only solution I can
think of so far is to catch the error then ignore it, but I don't want
to do this incase the error occurs somewhere outside of the address
book access, and is ignored, which could lead to all sorts of problems.

Also if you think my code could be improved in general then any
pointers would be great. I've only just started using vba and only just

started using notes too.
Cheers
Charlie

Aug 1 '06 #1
2 11804

What if you turn error handling on and handle the 91 error in your
code?

Public Sub MySub()
On Error Goto ErrHandler

<code>
Exit Sub

ErrHandler:
if Err.Number = 91 then
'skip the error and go to the next line.
Resume Next
Else
Handle Other Errors...
End if

Aug 1 '06 #2
Thanks for replying

Thats what I mean't in my previous post about catching the error and
ignoring it, and at the moment it looks like it's what I'm going to
have to use. There doesn't seem to be a lot of information around
regarding accessing lotus notes through the COM, which is a bit
annoying.

I think that because the lotus notes database is a document rather than
a relational database, if a field is blank then there is no entry, not
even a null, which means the field simply doesn't exist if there is no
data in it. I know that lotus can be a really a great program, but to a
beginner it's pretty tough getting it to do anything!

Cheers

Charlie

pi********@hotmail.com wrote:
What if you turn error handling on and handle the 91 error in your
code?

Public Sub MySub()
On Error Goto ErrHandler

<code>
Exit Sub

ErrHandler:
if Err.Number = 91 then
'skip the error and go to the next line.
Resume Next
Else
Handle Other Errors...
End if
Aug 1 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Mark Hewitt | last post by:
Hi, Has anybody had any experience sending HTML email to a Lotus Notes client? I am having a problem that the mail is arriving HTML to everyone except these clients. Does anyone know of any...
13
by: Sateesh | last post by:
Hi, Is it possible to access Lotus notes using Python? Can anyone provide me some pointers? Thanks Sateesh
5
by: NickBlooruk | last post by:
Hello, I have successfully linked a Lotus Notes server to our SQL Server database using an ODBC connection. This works fine when wanting to select records eg openquery(LOTUSNOTES2, 'select *...
0
by: PZ Fosbeck | last post by:
I'm not a Lotus Notes developer but thanks to this group's archives have successfully created a function for sending Lotus Notes emails from Access. The follow code works great except I want to...
1
by: Nicole | last post by:
Hello! I hope there is someone out there who can shed some light on this for me. I have a module that is supposed to look at an access table, pull out each bid record, link to another table to...
1
by: jeremy | last post by:
I found a simple piece of code in the past which allowed me to send email from msaccess through vba code. I cannot find it again on the web. I have found very long code on the web purported to do...
2
by: DeanL | last post by:
Hi Everyone, I'm not sure if this is even possible but I thought I'd ask anyway. I have an Access 97 database that contains construction projects and other associated details and is updated on...
1
by: Joe | last post by:
HI Has anyone been able to work with lotus notes automation classes??? Can you post sample code of how to use these classes. I have setup in VB but I am not able to port to C# This is what I...
0
by: kohligagan2 | last post by:
Hi, I am working on a scenario . And scenario is I am trying to send an Email using my Lotus notes Client Id ( Lotus notes :- is used for messaging and sending mails work as a middleware) I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.