如果当前尚未安装,是否可以添加对 Excel 版本的引用?

发布于 2024-09-17 09:55:18 字数 708 浏览 5 评论 0原文

使用 Visual Basic 2008 Express Edition

涉及 2 台 PC:

PC1 安装了 VBEE 和 Excel 2007
PC2(目标机)没有安装VBEE,但有Excel 2000

我想要完成的是在PC1上构建一个应用程序以在PC2上使用。

当然,当我在构建期间引用 12.0 库,然后尝试在目标计算机上使用 9.0 运行时,我收到一条“找不到 12.0 对象库”消息。另外,我无法使用后期绑定(如下所示):PC2 的安全设置显然禁止这样做...

    Dim objExcel As Object 'Excel.Application
    Dim objWB As Object 'Excel.Workbook
    Dim objWS As Object 'Excel.Worksheet
    Dim objRng As Object 'Excel.Range

    Try
        'Try to Open Excel, Add a workbook and worksheet
        objExcel = CreateObject("Excel.Application") 'New Excel.Application

    etc...

那么,有没有办法添加对 Excel 9.0 的引用,而无需将其实际安装在与 VBEE 相同的计算机上?

还有其他办法解决这个问题吗?

Using Visual Basic 2008 Express Edition

2 PCs are involved:

PC1 has VBEE and Excel 2007 installed
PC2 (target machine) does not have VBEE installed, and has Excel 2000

What I am trying to accomplish is to build an app on PC1 to use on PC2.

Of course, when I reference the 12.0 library during the build and then try to run using 9.0 on the target machine, I get a "can't find 12.0 object library" message. Also, I can't use late binding (as shown below): PC2's security settings apparently prohibit this...

    Dim objExcel As Object 'Excel.Application
    Dim objWB As Object 'Excel.Workbook
    Dim objWS As Object 'Excel.Worksheet
    Dim objRng As Object 'Excel.Range

    Try
        'Try to Open Excel, Add a workbook and worksheet
        objExcel = CreateObject("Excel.Application") 'New Excel.Application

    etc...

So, is there any way to add reference to Excel 9.0 without it actually being installed on the same machine as VBEE?

Is there any other way around this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

屋檐 2024-09-24 09:55:18

当然,我一直这样做。您需要从旧版本的机器上获取 TLB(或者您必须引用的主 EXE 或 DLL),将其复制到您的开发机器(最好在项目中的某个位置,这样您就可以将其放在 VCS 下,因为它只是因为您的项目源的一部分,然后设置对该 dll 的引用

我已经使用 Word、Excel、PPT 和 Outlook 成功完成了此操作,针对必须在从 Office 2000 到 Office 2000 的所有内容中运行的插件进行编码。 2010 年。

我从不同的机器上获取了所有相关的 TLB 和包含 TLB 的 DLL,将它们集中定位,并引用这些副本。

使用 .NET,您甚至可以同时引用多个 WORD tlb(尽管我实际上没有任何需要)。使用 VB6,您实际上无法做到这一点,但同样,您通常不需要这样做。

Sure, I do that all the time. You'll need to grab the TLBs (or the main EXE or DLL that you have to reference) from the machine with the older version, copy IT to your dev machine (preferably somewhere in your project so you can put it under VCS, cause it just because part of the source of your project, and then set your references to that dll.

I've successfully done this with Word, Excel, PPT, and Outlook, coding against an addin that had to run in everything from Office 2000 through 2010.

I grabbed all the relevant TLBs and DLLs that contained the TLBs from various machines, located them centrally, and referenced those copies.

With .NET, you can even simultaneously reference several WORD tlbs (though I didn't have any need to actually do it). With VB6, you can't really take it that far, but again, you generally shouldn't need to.

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