为什么这段代码会被破坏?

发布于 2024-11-08 20:12:43 字数 561 浏览 3 评论 0原文

我有一台本地机(即开发)和一台虚拟机(即生产)。在两者之间,我使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

伴我心暖 2024-11-15 20:12:43

Lotus.NotesSession 与 Notes.NotesSession 不同。您可能只需将 CreateObject 行更改为:

Set NtSession = CreateObject("Lotus.NotesSession")

Lotus.NotesSession is not the same as Notes.NotesSession. You might just need to change your CreateObject line to:

Set NtSession = CreateObject("Lotus.NotesSession")
榆西 2024-11-15 20:12:43

根据 Ken 的回复,我建议您决定是要晚绑定还是早绑定。

Global NtSession As Object
Set NtSession = CreateObject("Lotus.NotesSession")

或者

Global NtSession As lotus.NotesSession
Set NtSession = New Lotus.NotesSession

我只是看不到混合两者的价值,如

Global NtSession As lotus.NotesSession
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")
一页 2024-11-15 20:12:43

检查 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文