473,804 Members | 3,748 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.OpenR ecordset("Tempo rary 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("N otes.NotesSessi on")
'Open Address Book database
Set NotesDB = Session.GetData base("", "names.nsf" )
If NotesDB.IsOpen = True Then
'Do nothing
Else
NotesDB.OPENMAI L
End If
Set NotesView = NotesDB.GetView ("Contacts")
Set NotesViewNav = NotesView.Creat eViewNav()
Set NotesEntry = NotesViewNav.Ge tFirstDocument( )
While Not (NotesEntry Is Nothing)
Set NotesDoc = NotesEntry.Docu ment
fname = NotesDoc.GetFir stItem("FirstNa me").Values
lname = NotesDoc.GetFir stItem("LastNam e").Values
JobTitle = NotesDoc.GetFir stItem("JobTitl e").Values
CompanyName = NotesDoc.GetFir stItem("Company Name").Values
TempContactRST. AddNew
TempContactRST! FirstName = fname(0)
TempContactRST! LastName = lname(0)
TempContactRST! Company = CompanyName(0)
TempContactRST! JobTitle = JobTitle(0)
TempContactRST. Update
Set NotesEntry = NotesViewNav.Ge tNextDocument(N otesEntry)
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 11849

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********@hotm ail.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
9725
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 particular problems related to these clients? Here is my code....
13
15173
by: Sateesh | last post by:
Hi, Is it possible to access Lotus notes using Python? Can anyone provide me some pointers? Thanks Sateesh
5
5022
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 * from Person' ) The problem I have is when I try to update the record I get an error eg update openquery(LOTUSNOTES, 'select * from Person where
0
5617
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 remove my name from the 'Sent By' portion of the email. These messages are sent using my client session of Lotus Notes, using a database called 'Tech Team' The resulting email message headers contains (Bold, the From name) 'Tech Team'
1
4495
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 find all of the people to send the email to and link to one more table to find who should be cc'd on the note. All of this works fine, except.... The arrays for the To and CC seem to exclude names from the list if there are multiple recipients...
1
2022
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 this but it does not work for me. I believe I may have been using apisendmessage but I really don't remember. I only remember that the code was only a few lines and it worked to send an automatic email through lotus notes when it was open in...
2
1723
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 a regular basis by construction engineers and the like. My problem is that ocassionally (actually, more like daily) emails are received from other project engineers with numbered comments and ocassionally answers or comments to each numbered...
1
13052
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 have so far - I cannot create a session and not sure how to setup From/Subject
0
1798
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 have an ASP .NET website running on a IIS Server with Lotus note is running at the machine where server is running. One client sends the request to the server and correspondingly mail goes to the respective person as mentioned. I am using a...
0
9706
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10583
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10323
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9160
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7622
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5654
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4301
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3822
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2995
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.