由于 2016 年 1 月的 Office 更新,Excel VBA“自动化错误”,可能是由 MSCOMCTL.OCX (Microsoft Windows Common Controls 6.o (Service Pack 6)) 引起的

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34803843/
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-08 10:10:45  来源:igfitidea点击:

Excel VBA "Automation Error" due to Jan 2016 Office Update, probably caused by MSCOMCTL.OCX (Microsoft Windows Common Controls 6.o (Service Pack 6))

excelvbaexcel-vbatreeview

提问by Thomas Basset

Solution

解决方案

I have added a Treeview Active X Control to one of our spreadsheet, using Microsoft Windows Common Controls 6.0 (Service Pack 6), i.e. MSCOMCTL.OCXwhich lives in C:\Windows\SysWOW64\

我已使用 Microsoft Windows Common Controls 6.0(Service Pack 6)向我们的电子表格之一添加了一个 Treeview Active X 控件,即MSCOMCTL.OCX位于C:\Windows\SysWOW64\

KB2881029 (Security Update for Microsoft Office 2010 32-Bit Edition) (MS16-004), pushed out from Microsoft on 2016-01-15 (or thereabouts), installs a new version of MSCOMCTL.OCX(v6.1.98.46) which was "Created" on 2015-12-09, but "Accessed" (i.e. installed on the computer) at the time of the update.

KB2881029(Microsoft Office 2010 32 位版安全更新)(MS16-004),于 2016 年 1 月 15 日(或左右)从 Microsoft 推出,安装了新版本的MSCOMCTL.OCX(v6.1.98.46),它是“创建” 在 2015-12-09,但在更新时“已访问”(即安装在计算机上)。

This made the workbook "lose" reference to MSCOMCTL.OCX(quote marks on "lose", because the reference is still ticked but no longer works; the workbook doesn't compile because of "Compile error: Object library feature not supported" or "Automation error").

这使得工作簿“丢失”引用MSCOMCTL.OCX(“丢失”上的引号,因为引用仍然被勾选但不再有效;工作簿无法编译,因为“编译错误:不支持对象库功能”或“自动化错误”)。

It seems that the update modifies the following registry key by adding a SubKey 2.0, but leaves it empty, and doesn't register the new MSCOMCTL.OCX:

似乎更新通过添加 SubKey 2.0 修改了以下注册表项,但将其留空,并且不注册新的MSCOMCTL.OCX

HKEY_CLASSES_ROOT\TypeLib\{831FDD16-0C5C-11D2-A9FC-000F8754DA1}\

Fixing the problem requires three steps:

解决问题需要三个步骤:

  1. MSCOMCTL.OCXneeds to be unregistered and re-registered from an elevated command prompt, as follows:

    C:\Windows\system32>Regsvr32 /u C:\Windows\SysWOW64\MSCOMCTL.OCX 
    C:\Windows\system32>Regsvr32 C:\Windows\SysWOW64\MSCOMCTL.OCX
    

    When registering the new MSCOMCTL.OCX(Version 6.1.98.46) via REGSVR32, a new key is added to the Registry:

    KEY_CLASSES_ROOT\TypeLib\{831FDD16-0C5C-11D2-A9FC-000F8754DA1}.2
    

    If there was a SubKey named 2.1 already existing, it enters a reference that 2.2 is now the Key for use. But it doesn't do anything to the empty 2.0 SubKey !

    If there is a 2.0 (or 2.1 for that matter) SubKey with nothing in it, any object using that OCX should fail to create because it will use the 2.0 (resp 2.1) Version, it can't and didn't check for 2.2 Version.

  2. Clean up the registry by deleting the wrong or superseded keys 2.0 and 2.1, leaving only the latest and working key 2.2. This can be done from the Registry Editor by selecting HKEY_CLASSES_ROOT, Edit/Find/MSCOMCTRL.OCX.

    (Note: this step seems optional as I have checked that doing only step 1 and 3 made the workbook work again. But it feels like the right thing to do)

  3. In the in the Excel workbook VBA project, Microsoft Windows Common Controls 6.0 (Service Pack 6) needs to be unreferenced and re-referenced. Re-referencing is not just a matter of re-ticking the box, you need to use "Browse", and select MSCOMCTL.OCXin C:\Windows\SysWOW64\

    (Note, in the browser window, you need to change the file type from "dll" to "OCX" (or "all"))

  1. MSCOMCTL.OCX需要从提升的命令提示符取消注册并重新注册,如下所示:

    C:\Windows\system32>Regsvr32 /u C:\Windows\SysWOW64\MSCOMCTL.OCX 
    C:\Windows\system32>Regsvr32 C:\Windows\SysWOW64\MSCOMCTL.OCX
    

    MSCOMCTL.OCX通过 REGSVR32注册新的(版本 6.1.98.46)时,会在注册表中添加一个新项:

    KEY_CLASSES_ROOT\TypeLib\{831FDD16-0C5C-11D2-A9FC-000F8754DA1}.2
    

    如果已经存在名为 2.1 的 SubKey,它会输入一个引用,说明 2.2 现在是要使用的 Key。但它对空的 2.0 SubKey 没有任何作用!

    如果有一个 2.0(或 2.1)子密钥,其中没有任何内容,则使用该 OCX 的任何对象都应该无法创建,因为它将使用 2.0(对应 2.1)版本,它不能也没有检查 2.2版本。

  2. 通过删除错误的或被取代的密钥 2.0 和 2.1 来清理注册表,只留下最新的和可用的密钥 2.2。这可以在注册表编辑器中通过选择 HKEY_CLASSES_ROOT、Edit/Find/MSCOMCTRL.OCX 来完成。

    (注意:这一步似乎是可选的,因为我已经检查过只执行第 1 步和第 3 步就可以使工作簿再次工作。但感觉这是正确的做法)

  3. 在 Excel 工作簿 VBA 项目中,需要取消引用和重新引用 Microsoft Windows Common Controls 6.0(Service Pack 6)。再参考不仅仅是一个重新勾选框的事情,你需要使用“浏览”,然后选择MSCOMCTL.OCXC:\Windows\SysWOW64\

    (注意,在浏览器窗口中,您需要将文件类型从“dll”更改为“OCX”(或“all”))

Daniel Alexander Karr (refer post further below) has kindly shared a script he wrote to do steps 1 and 2 automatically (note that needs to be run as an Administrator).

Daniel Alexander Karr(请参阅下面的帖子)友好地分享了他编写的脚本来自动执行第 1 步和第 2 步(请注意,需要以管理员身份运行)。

Thanks Daniel and wmelonman for your help in understanding the problem and finding a solution.

感谢 Daniel 和 wmelonman 在理解问题和找到解决方案方面提供的帮助。

Original Post

原帖

Similarly to what is described in this 3 year old post (VBA Automation Errors due to Office Service Pack 3.0 caused by Forms), a perfectly working workbook of mine stopped working from one day to the next...

类似于这篇 3 年前的帖子 (由于表单引起的 Office Service Pack 3.0 导致 VBA 自动化错误)中所描述的内容,我的一本完美工作的工作簿从一天到一天停止工作......

In the list of updates carried out last night the following ones are Office Updates:

在昨晚进行的更新列表中,以下是 Office 更新:

  • KB3114563 (Definition Update for Microsoft Office 2010 32-Bit Edition)
  • KB2881029 (Security Update for Microsoft Office 2010 32-Bit Edition)
  • KB3114555 (Update for Microsoft Office 2010 32-Bit Edition)
  • KB3114553 (Security Update for Microsoft Office 2010 32-Bit Edition)
  • KB3114564 (Security Update for Microsoft Excel 2010 32-Bit Edition)
  • KB3114563(Microsoft Office 2010 32 位版的定义更新)
  • KB2881029(Microsoft Office 2010 32 位版安全更新)
  • KB3114555(Microsoft Office 2010 32 位版更新)
  • KB3114553(Microsoft Office 2010 32 位版安全更新)
  • KB3114564(Microsoft Excel 2010 32 位版安全更新)

There were other updates, but general Microsoft Windows updates, not specific to Office, and they hopefully are not relevant here.

还有其他更新,但一般的 Microsoft Windows 更新,并非特定于 Office,希望它们与此处无关。

My understanding is that the "Automation error" is due to the project not compiling because of the presence of 2 "additional" ActiveX controls on one of my forms that I have referenced from Microsoft Windows Common Controls 6.0 (Service Pack 6), i.e., MSCOMCTL.OCXwhich lives in C:\Windows\SysWOW64\

我的理解是,“自动化错误”是由于项目没有编译,因为在我从 Microsoft Windows Common Controls 6.0 (Service Pack 6) 引用的表单之一上存在 2 个“附加”ActiveX 控件,即,MSCOMCTL.OCX住在C:\Windows\SysWOW64\

Unfortunately un-registering and re-registering MSCOMCTL.OCXas explained in the aforementioned postdidn't solve the problem.

不幸的是,MSCOMCTL.OCX如上述帖子中所述,取消注册和重新注册并没有解决问题。

I also tried deleting all *.exd, but there weren't any on my C:drive.

我也尝试删除 all *.exd,但我的C:驱动器上没有。

Additional info that may be relevant:

可能相关的其他信息:

  • The MSCOMCTL.OCXfile version is 6.1.98.46, created & last modified 2015-12-09 but accessed at 3.33am yesterday (2016-01-15), i.e. about the same time the updates occurred (3:14am for the latest one).
  • Once passed the initial "automation error" message, I would get an additional message, "Compile error: Object library feature not supported", highlighting lines of codes associated with the additional controls.
  • I've verified these were "causing" the problem by creating a blank form an trying to add one on. I got the error message "Could not complete the operation due to error 800a0011".
  • These additional controls are Microsoft TreeView Control 6.0 (SP6) and Microsoft ImageList Control 6 (SP6).
  • I could add the Microsoft TreeView Control, Version 5.0 (SP2) and Microsoft ImageList Control, Version 5.0 (SP2) without raising the error (I didn't try making them work though).
  • MSCOMCTL.OCX文件版本6.1.98.46,创建和最后修改2015年12月9日,但在上午03点33访问昨日(2016年1月15日),即大约在同一时间发生的更新(上午最新的一个3:14)。
  • 一旦通过最初的“自动化错误”消息,我将收到一条附加消息,“编译错误:不支持对象库功能”,突出显示与附加控件关联的代码行。
  • 我已经通过创建一个空白表单并尝试添加一个来验证这些是“导致”问题的。我收到错误消息“由于错误 800a0011 无法完成操作”。
  • 这些附加控件是 Microsoft TreeView Control 6.0 (SP6) 和 Microsoft ImageList Control 6 (SP6)。
  • 我可以添加 Microsoft TreeView Control, Version 5.0 (SP2) 和 Microsoft ImageList Control, Version 5.0 (SP2) 而不会引发错误(虽然我没有尝试让它们工作)。

Does anyone know of similar mishap with MSCOMCTL.OCXfollowing yesterday's Microsoft updates? That may confirm it could be the source of my problem.

有谁知道在MSCOMCTL.OCX昨天的 Microsoft 更新之后发生了类似的事故?这可能证实它可能是我问题的根源。

Does anyone know of a fix?

有谁知道修复?

Does anyone know how to report this to Microsoft (if indeed it is the source of the problem)?

有谁知道如何向微软报告这个问题(如果它确实是问题的根源)?

And finally, for those interested, there is a way to avoid Microsoft Updates messing up ActiveX controls...not using them! This is what JPK has done for his TreeView.

最后,对于那些感兴趣的人来说,有一种方法可以避免 Microsoft 更新弄乱 ActiveX 控件……不使用它们!这就是 JPK 为他的TreeView所做的。

采纳答案by Thomas Basset

Thanks all for your contributions,
I have found that de-referencing and re-referencing the Microsoft Windows Common Controls 6.0 (Service Pack 6) in the Excel VBA project would finally make it work.
!!!...BUT...!!!
Simply un-ticking / re-ticking the tick box would be too simple ! For re-referencing it, you need to use "browse", and select MSCOMCTL.OCX in c:\Windows\SysWOW64\
(note, in the browser window, you need to change the file type from "dll" to "OCX" (or "all"))
I have tried simply doing this on a machine where I hadn't run Daniel Alexander's Patch (to un-register and re-register MSCOMCTL.OCX, and remove the old empty 2.0 key from the register), and it didn't work, so I expect the above steps are required. I will try to thoroughly test which steps are necessary and edit this answer to spell out the whole procedure, step by step, but for the time being running Daniel Alexander's patch (AS ADMINISTRATOR !) and re-referencing Microsoft Windows Common Controls 6.0 (Service Pack 6) in the Excel VBA project seem to work.

感谢大家的贡献,
我发现在 Excel VBA 项目中取消引用和重新引用 Microsoft Windows Common Controls 6.0(Service Pack 6)最终会使其工作。
!!!...但...!!!
简单地取消勾选/重新勾选复选框太简单了!要重新引用它,您需要使用“browse”,并在 c:\Windows\SysWOW64\ 中选择 MSCOMCTL.OCX
(注意,在浏览器窗口中,您需要将文件类型从“dll”更改为“OCX” (或“全部”))
我曾尝试在没有运行 Daniel Alexander's Patch 的机器上简单地执行此操作(取消注册并重新注册 MSCOMCTL.OCX,并从寄存器中删除旧的空 2.0 密钥),但它不起作用,所以我希望上述步骤是必需的。我将尝试彻底测试哪些步骤是必要的,并编辑此答案以逐步说明整个过程,但目前正在运行 Daniel Alexander 的补丁(AS ADMINISTRATOR!)并重新引用 Microsoft Windows Common Controls 6.0(服务Pack 6) 在 Excel VBA 项目中似乎可以工作。

回答by Daniel Alexander Karr

our Business-ERP-Software Faktura-XP got the same problem since yesterday, we investigated the Problem and created a Patch for it, maybe it will help someone:

我们的 Business-ERP-Software Faktura-XP 从昨天开始就遇到了同样的问题,我们调查了这个问题并为它创建了一个补丁,也许它会帮助某人:

http://www.faktura-xp.de/faktura-xp-download/update-und-patch-oeffentlich.html#toggle-id-4

http://www.faktura-xp.de/faktura-xp-download/update-und-patch-oeffentlich.html#toggle-id-4

In our Case, the TreeViewControl stopped working, but it will be the same Problem with Automatition. Microsoft updated the MSCOMCTL.OCX to Version 2.2, if the Key {831FDD16-0C5C-11D2-A9FC-000F8754DA1} has an empty 2.1 or 2.0 Entry the Common Control will stop working. Solution: Delete Key 2.0 and 2.1, leave 2.2, unregister the mscomctl.ocx and reregister it.

在我们的案例中,TreeViewControl 停止工作,但它会与自动化相同的问题。Microsoft 将 MSCOMCTL.OCX 更新到版本 2.2,如果密钥 {831FDD16-0C5C-11D2-A9FC-000F8754DA1} 有一个空的 2.1 或 2.0 条目,公共控件将停止工作。解决方法:删除Key 2.0和2.1,保留2.2,注销mscomctl.ocx并重新注册。

Our Patch will do exactly this, nothing more, nothing less, but as simple as possible for our customers, just click Next and Close.

我们的补丁将完全做到这一点,仅此而已,但对我们的客户来说尽可能简单,只需单击下一步并关闭。

Edited for more information:

编辑以获取更多信息:

HKEY_CLASSES_ROOT\TypeLib\{831FDD16-0C5C-11D2-A9FC-000F8754DA1}.2

is freshly created when register the new MSCOMCTL.OCX (Version 6.1.98.46) via REGSVR32

通过 REGSVR32 注册新的 MSCOMCTL.OCX(版本 6.1.98.46)时新创建的

When there is a SubKey named 2.1 it enters a reference that 2.2 is now the Key for use.

当有一个名为 2.1 的子密钥时,它会输入一个引用,即 2.2 现在是要使用的密钥。

If there is a 2.1 SubKey with nothing in it, your Object will fail to create because it will use the 2.1 Version, can't and didn't check for 2.2 Version.

如果有一个 2.1 子密钥,里面什么都没有,你的对象将无法创建,因为它将使用 2.1 版本,不能也没有检查 2.2 版本。

Delete this Key if neccessary and youre good to go.

如有必要,删除此密钥,您就可以开始了。

Further Testings shows that 2.0 SubKey is obsolete and could cause Problems.

进一步的测试表明 2.0 SubKey 已经过时并可能导致问题。

Mostly Systems with Microsoft Windows 7 had this Problem. For our Software, no-one with Windows 8.1 or Windows 10 called a Problem after the current Update.

大多数使用 Microsoft Windows 7 的系统都有这个问题。对于我们的软件,在当前更新之后,Windows 8.1 或 Windows 10 没有人称其为问题。

回答by wmelonman

Similiar problem here: Ancient Access 97 app on ancient XP (not for long anymore, sigh of relief) quits saying "Error 91: Object variable or With block variable not set". Examination showed it happens when the progress bar control which resides in Mscomctl.ocx is adressed.

这里有类似的问题:古代 XP 上的古代 Access 97 应用程序(不再长,松了一口气)退出说“错误 91:对象变量或块变量未设置”。检查表明当位于 Mscomctl.ocx 中的进度条控件被寻址时会发生这种情况。

I found that KB2881029 (MS16-004) is the culprit. It installs the new version of MSCOMCTL.OCX. On machines w/o this update the Access app works fine. But it is not suited for removal, at least this is what our WSUS told me when I was going for it. Anyway we wouldn't want to live w/o a security update.

我发现 KB2881029 (MS16-004) 是罪魁祸首。它安装新版本的 MSCOMCTL.OCX。在没有此更新的机器上,Access 应用程序运行良好。但它不适合删除,至少这是我们的 WSUS 在我打算删除时告诉我的。无论如何,我们不想在没有安全更新的情况下生活。

Having read the answer concerning HKCR\TypeLib{831FDD16... I tried deleting the at that time still populated \2.0 subkey prior to installing the update only to find out that even with a non existing \2.0 subkey the update does create the empty one on installation. Well done, Microsoft...!

阅读有关 HKCR\TypeLib{831FDD16... 的答案后,我尝试在安装更新之前删除当时仍然填充的 \2.0 子项,结果发现即使使用不存在的 \2.0 子项,更新也会创建空的在安装。干得好,微软……!

回答by cypizek

The problem has been described in detail here:

这里已经详细描述了这个问题:

"Error messages or Access crashes after you install security update MS16-004"
MS: Article ID: 3139567
(Last Review: 02/16/2016 19:15:00 - Revision: 3.0)

“安装安全更新 MS16-004 后出现错误消息或访问崩溃”
MS:文章 ID:3139567
(上次审核:02/16/2016 19:15:00 - 修订版:3.0)

https://support.microsoft.com/en-us/kb/3139567

https://support.microsoft.com/en-us/kb/3139567