I have a local machine (i.e. Development) and a virtual开发者_运维问答 machine (i.e. Production). Between the 2, I develop and maintain a few automated reports using Access, Excel, and Lotus Notes.
Recently, I was tasked with a new report that was very similar to an existing one. So, I just copied the appropriate Access file from Production back to Development to rework it. And it failed. With some trial & error, I've narrowed it down to this snippet:
Option Compare Database
Option Explicit
Global NtSession As lotus.NotesSession
Sub Main()
Set NtSession = CreateObject("Notes.NotesSession")
...
End Sub
Again, this code works fine in Production, but it now breaks when I try to run in on my Development (I get a "Type Mismatch" error on the CreateObject). The easiest way around this is to just to develop my report in Production, but that kind of defeats the purpose, not to mention the oddity that it used to work on my local machine in the first place and now it doesn't. So, why is this throwing an error on my local machine (i.e. Dev), but not in the virtual (i.e. Production)?
Lotus.NotesSession is not the same as Notes.NotesSession. You might just need to change your CreateObject line to:
Set NtSession = CreateObject("Lotus.NotesSession")
Based on Ken's response, I suggest you decide whether you want late or early binding.
Global NtSession As Object
Set NtSession = CreateObject("Lotus.NotesSession")
or
Global NtSession As lotus.NotesSession
Set NtSession = New Lotus.NotesSession
I just don't see the value of mixing the two, as in
Global NtSession As lotus.NotesSession
Set NtSession = CreateObject("Lotus.NotesSession")
Check that COM object nlsxbe.dll is installed and properly registered on your development machine. Maybe unregister and reregister it just to be sure. Do a Google search for "nlsxbe.dll register" for more tips about problems involving that module, which should be installed (but maybe not registered) as part of the Notes Client install.
精彩评论