2
votes

I'm trying to connect to a Lotus Notes database via VBA in Microsoft Access 2003. The code I have is as follows:

Set nSession = CreateObject("Notes.NotesSession")

Set nDatabase = nSession.GetDatabase("CN=MT_N01/O=Org Name", "LossPrevention\BrchPrVI.nsf", False)

I've tried variations for the server name, but nothing seems to work. In Lotus Notes it appears as "Server: MT_N01/Org Name". I've tried just "MT_N01" and "MT_N01/Org Name", but the NotesDatabase variable keeps ending up empty.

Any tips?

3

3 Answers

2
votes

I might be wrong here, but I think you should call the Initialize() method of the session prior to using it.

Take a look at the samples here: http://www.ibm.com/developerworks/lotus/library/domino-msnet/index.html

2
votes

I think that behaviour is normal; VBA knows nDatabase is a variant/object, but does not know anything about its contents. At least that is what I get when I try your code in Excel 2003.

Try to return something from the database object, for example nDatabase.ReplicaID should return the database identity string. If the databas is not properly loaded, you will get an error.

Many good links are posted in response to the ".NET and Lotus Notes Interop." question.

0
votes

Unless you also need to us the NotesUIWorkspace class and its child classes to manipulate the Notes client user interface, you should be using the "Lotus.NotesSession" class instead of the "Notes.NotesSession" class. And as per the answer from @Sagultay, you should be calling nSession.Intialize().