VBA 兼容性问题:64 位 Windows7(缺少 MSINET)和 Trim 功能兼容性问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11449858/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 16:51:04  来源:igfitidea点击:

VBA compatibility issues: 64-bit Windows7 (MSINET missing) and Trim function compatibility issues

excelvbaexcel-vbamsinet

提问by Gionata

I'm trying to upgrading a VB Excel application working on Windows XP 32-bit to Windows 7 64-bit operating system. There are two issues affecting such operation. I have found that these topics are not uncommon.

我正在尝试将在 Windows XP 32 位上运行的 VB Excel 应用程序升级到 Windows 7 64 位操作系统。有两个问题会影响这种操作。我发现这些话题并不少见。

  1. The VBA script has to connect to a server requiring Microsoft Internet Transfer Protocol 6.0 (SP 6.0) - MSINET registered in System32 directory. Unfortunately the aforementioned library works on 32-bit operating systems only and no release is available for 64-bits. I've tried to import to Reference List: this seems to work, however once I restart the application no dll (merely a ocx file - Active X) could be found. Obviously the dll cannot be registered through regsvr32 application. There's something similar to MSINET working on 64-bit version of Windows?

  2. The second issue I found is not related to the previous one. The application need to parse an input string removing white spaces. The old VBA uses TRIM and I suppose I have to make no changes about it. However the compiling operation results in the following error: "Compile error: Can't find project or library". No references are missing (except for MSINET).

  1. VBA 脚本必须连接到需要 Microsoft Internet 传输协议 6.0 (SP 6.0) - 在 System32 目录中注册的 MSINET 的服务器。不幸的是,上述库仅适用于 32 位操作系统,并且没有适用于 64 位的版本。我尝试导入到参考列表:这似乎有效,但是一旦我重新启动应用程序,就找不到 dll(仅仅是一个 ocx 文件 - Active X)。显然 dll 不能通过 regsvr32 应用程序注册。在 64 位版本的 Windows 上有类似 MSINET 的东西吗?

  2. 我发现的第二个问题与前一个无关。应用程序需要解析输入字符串并删除空格。旧的 VBA 使用 TRIM,我想我不必对其进行任何更改。但是编译操作会导致以下错误:“编译错误:找不到项目或库”。没有缺少任何引用(MSINET 除外)。

I'm on a 64-bit Windows 7, Office 2010, microsoft.office.interop.excel.dll 14 installed. Thank you

我使用的是 64 位 Windows 7,Office 2010,已安装 microsoft.office.interop.excel.dll 14。谢谢

回答by GSerg

  1. 32-bit software works just fine on 64-bit systems. You don't want a 64-bit ocx, you won't be able to use it anyway. There are plently manuals available on Google on how to register a 32-bit ocx on a 64-bit Windows 7, such as this one.
  2. As soon as you fix the missing ocx reference, the missing trim function will fix itself. Again, you could find this out yourselfwith a search.
  1. 32 位软件在 64 位系统上运行良好。您不想要 64 位 ocx,无论如何您都无法使用它。谷歌上有很多关于如何在 64 位 Windows 7 上注册 32 位 ocx 的手册,比如这个
  2. 一旦您修复了缺失的 ocx 引用,缺失的修剪功能就会自行修复。同样,您可以通过搜索自己找到这一点

If, however, you have 64-bit office, you will not be able to use msinet control at all, and the trim function will not reappear until you remove the reference to msinet.

但是,如果您有 64 位 office,您将根本无法使用 msinet 控件,并且除非您删除对 msinet 的引用,否则修剪功能将不会重新出现。

回答by Vitor Morgado

In some windows instalations i wasn't able to register OCX under System32. As this became a normal issue in my company, my method to solve this is:

在某些 Windows 安装中,我无法在 System32 下注册 OCX。由于这成为我公司的正常问题,我解决此问题的方法是:

  • Create a folder called OCX in the Drive ( it can be anywher you want )
  • Place the OCX there
  • Start cmd.exe as Administrator
  • Register the OCX in that folder:

    C:\Windows\System32> regsvr32.exe C:\OCX\mscomctl.ocx 
    
  • 在 Drive 中创建一个名为 OCX 的文件夹(它可以在任何你想要的地方)
  • 将 OCX 放在那里
  • 以管理员身份启动 cmd.exe
  • 在该文件夹中注册 OCX:

    C:\Windows\System32> regsvr32.exe C:\OCX\mscomctl.ocx 
    

This works everytime.

这每次都有效。

Do not delete the OCX folder.

不要删除 OCX 文件夹。



EDIT:

编辑:

In a fresh windows 7 / 8 install, i've been able to run the same applications without registering the OCX by running the Office App ( i.e. Access) with Administration Previleges. Discovered it because of a print server that was giving the same OCX problems. Probably this can be fixed by editing the OCX permissions rather than run as Administrator.

在全新的 Windows 7 / 8 安装中,通过使用管理权限运行 Office 应用程序(即 Access),我无需注册 OCX 即可运行相同的应用程序。发现它是因为打印服务器出现了相同的 OCX 问题。这可能可以通过编辑 OCX 权限而不是以管理员身份运行来解决。