为什么这段代码会被破坏?
我有一台本地机(即开发)和一台虚拟机(即生产)。在两者之间,我使用 Access、Excel 和 Lotus Notes 开发和维护一些自动化报告。
最近,我的任务是编写一份与现有报告非常相似的新报告。因此,我只是将适当的 Access 文件从“生产”复制回“开发”以对其进行修改。但它失败了。经过一些尝试&错误,我已将其范围缩小到以下代码片段:
Option Compare Database
Option Explicit
Global NtSession As lotus.NotesSession
Sub Main()
Set NtSession = CreateObject("Notes.NotesSession")
...
End Sub
同样,此代码在生产中运行良好,但现在当我尝试在开发中运行时它会中断(我在 CreateObject 上收到“类型不匹配”错误)。解决这个问题的最简单的方法是在生产中开发我的报告,但这违背了目的,更不用说它曾经在我的本地计算机上工作的奇怪之处,现在却不能了。那么,为什么这会在我的本地计算机(即开发)上引发错误,但在虚拟机(即生产)中不会引发错误?
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)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Lotus.NotesSession 与 Notes.NotesSession 不同。您可能只需将 CreateObject 行更改为:
Lotus.NotesSession is not the same as Notes.NotesSession. You might just need to change your CreateObject line to:
根据 Ken 的回复,我建议您决定是要晚绑定还是早绑定。
或者
我只是看不到混合两者的价值,如
Based on Ken's response, I suggest you decide whether you want late or early binding.
or
I just don't see the value of mixing the two, as in
检查 COM 对象 nlsxbe.dll 是否已安装并在您的开发计算机上正确注册。也许注销并重新注册只是为了确定。在 Google 上搜索“nlsxbe.dll register”,以获取有关该模块问题的更多提示,该模块应作为 Notes 客户端安装的一部分进行安装(但可能未注册)。
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.