64 位 Windows 7 上的 Excel 2003 会自动更改对 SysWOW64MSCOMCTL.OCX 的引用,因此 32 位 Excel 会抱怨 [英] Excel 2003 on 64-bit Windows 7 automatically changes reference to SysWOW64MSCOMCTL.OCX so 32-bit Excel complains

查看:28
本文介绍了64 位 Windows 7 上的 Excel 2003 会自动更改对 SysWOW64MSCOMCTL.OCX 的引用,因此 32 位 Excel 会抱怨的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Excel 2003 VBA 项目中,我使用 MSCOMCTL.OCX 中的控件.即 VBA 项目引用了 System32MSCOMCTL.OCX.

In an Excel 2003 VBA project I am using controls from MSCOMCTL.OCX. That is the VBA project has a reference to System32MSCOMCTL.OCX.

当我在 64 位 Windows 7 系统上的 Excel 2003 中打开该项目时,Excel 会自动更改对 SysWOW64MSCOMCTL.OCX(这是正确的位置)的引用.

When I open that project in Excel 2003 on my 64-bit Windows 7 system, Excel automatically changes the reference to SysWOW64MSCOMCTL.OCX (which is the correct location).

但是,当我将该项目发送给使用 32 位 Windows XP 的客户时,该项目在打开时会报错,因为他的系统上不存在 SysWOW64MSCOMCTL.OCX.

However, when I send that project to my client who is using 32-bit Windows XP, the project complains during opening because SysWOW64MSCOMCTL.OCX does not exist on his system.

以下是我目前想到的(不满意的)解决方案:

Here are the (unsatisfactory) solutions I came up with so far:

  1. 指示客户手动将引用更改回其系统上的正确位置 (System32MSCOMCTL.OCX).

  1. Instruct the client to manually change the reference back to the correct location on his system (System32MSCOMCTL.OCX).

  • 这实际上不起作用,原因如下:
  • This does not really work for the following reasons:
  1. 当 Excel 2003 32 位打开工作表并且找不到对 MSCOMCTL 的引用时,它会从表单中删除来自库(例如 TreeCtrl)的所有控件:-(
  2. 客户正在为这个程序而苦苦挣扎,这对他来说非常麻烦.

  • 同上问题:当打开工作簿时 VBA 编译失败,Excel 会删除所有在表单中找不到的控件.
  • 这实际上可以工作,但是目前我正在努力将事件处理程序绑定到控件(但这将是单独的问题;-)

方法 1. 和 2. 并没有真正解决任何问题,而解决方案 3 需要大量工作.

Approaches 1. and 2. do not really solve anything and solution 3 is a lot of work.

任何想法将不胜感激.

推荐答案

如果在工作簿关闭时自动关闭引用会怎样?这样当工作簿打开时引用不会被破坏",并且您的所有控制都应该仍然很好.

What if you automatically turned the reference off when the workbook closed? that way the reference wouldn't be 'broken' when the workbook is opened, and all your control should still be good.

即:

Private Sub Workbook_Open()
'use environ variable for folder locs
If os = "64bit" Then
    Me.VBProject.References.AddFromFile ("C:WINDOWSSysWOW64MSCOMCTL.OCX")
Else
    Me.VBProject.References.AddFromFile ("C:WINDOWSsystem32MSCOMCTL.OCX")
End If
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
    For Each ref In Me.VBProject.References
       If ref.Name = "MSComctlLib" Then
        Me.VBProject.References.Remove ref
       End If
        Next ref
End Sub

我对 ADODB dll 进行了快速测试,它似乎有效,但我不确定您具体是如何使用该 DLL 的;不过,让我知道这是否有效!当然比选项 3 好很多!

I did a quick test with the ADODB dll and it seemed to work,but I am not sure how you're using that DLL specifically; let me know if that works, though! Sure a lot better than option 3!

这篇关于64 位 Windows 7 上的 Excel 2003 会自动更改对 SysWOW64MSCOMCTL.OCX 的引用,因此 32 位 Excel 会抱怨的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆