excel - 无法在 VBA 中创建 Scripting.Dictionary 或 MSXML.DOMDocument60,因为 Windows 更新 KB4586781
问题描述
从标准库(如 Microsoft Scripting Runtime 或 Microsoft Xml, v6.0)创建 COM 对象时,某些 VBA 代码不再适用于我。我在实例化行出现错误,错误是代码 80004021(-2147467231),错误描述是Automation error The operation attempted is not supported.
但是我可以创建具有对这些库的互操作引用的 C# 代码非常好。两天前我有一个Windows 10 更新 KB4586781。
Excel VBA 和 Word VBA 中的代码均失败。还有其他人有类似问题吗?
Sub TestCreate_Scripting_Dictionary()
'* THIS CODE FAILS !!!!
Dim lateBound As Object
Set lateBound = VBA.CreateObject("Scripting.Dictionary") '<=== FAILS 80004021
' ... Automation error The operation attempted is not supported.
'* Tools->References->Microsoft Scripting Runtime
Dim dict As Scripting.Dictionary
Set dict = New Scripting.Dictionary '<=== FAILS 80004021
' ... Automation error The operation attempted is not supported.
End Sub
Sub TestCreate_MSXML2_DOMDocument60()
'* THIS CODE FAILS !!!!
'* Tools->References->Microsoft Xml, v6.0
Dim xml As MSXML2.DOMDocument60
Set xml = New MSXML2.DOMDocument60 '<=== FAILS 80004021
' ... Automation error The operation attempted is not supported.
End Sub
更新:我打算重新安装,但它没有任何干预就消失了。奇怪的。
解决方案
推荐阅读
- php - 我不明白如何声明不同类别的数据库表
- javascript - SVG中的单击事件坐标
- r - 使用循环和自定义函数替换列中的值 - R
- python - 使用python进行网络抓取并且值不存在时如何防止错误?
- raspberry-pi - 无法在 Raspberry Pi 上挂载 CIFS,因为 CIFS 未在 /proc/filesystem 中列出(并且找不到其模块)
- ruby-on-rails - 将敏感和较短的数据传递到外部链接
- firebase - Firebase DataSnapshot 检索已删除/不存在的节点
- r - 如何将每个替代行带到下一列
- python - 你如何使用 nuitka 共享对象文件?
- python - 如果我更改循环内的值,Python为什么循环行为不会改变