excel - VBA 运行时错误 5941 请求的集合成员不存在
问题描述
我有从 excel 文档获取信息的 word doc,但是在打开 word doc 时出现上述错误。我有很多 word 文档可以很好地使用,但有些我得到了上面的运行时错误。下面是我调试时突出显示的 VBA 代码:
Windows(ActiveDocument.Name).Activate
' add registry keys if necessary
Dim wShell As Object
Set wShell = CreateObject("WScript.Shell")
On Error Resume Next
gsKeyValue1 = wShell.RegRead(Key1) ' initial value of key, save for restoring user's key
gsKeyValue2 = wShell.RegRead(Key2) ' initial value of key, save for restoring user's key
On Error GoTo 0
If gsKeyValue1 = "" Or gsKeyValue1 = "0" Then wShell.RegWrite Key1, 1, "REG_DWORD"
If gsKeyValue2 = "" Or gsKeyValue2 = "0" Then wShell.RegWrite Key2, 1, "REG_DWORD"
' close Document1
On Error Resume Next
Documents("Document1").Close
On Error GoTo 0
Initialize
Windows(ActiveDocument.Name).Activate
Application.WindowState = wdWindowStateNormal
Application.Left = 10
Application.Top = 20
Application.Width = 920
Application.Height = 680
If MsgBox("Would you like to update the links to the Excel spreadsheet? (This is only necessary if the data has recently been updated.", vbYesNo) = vbYes Then
Macro1_UpdateLinks
End If
End Sub
我该如何纠正这个错误。
解决方案
推荐阅读
- fork - 如何分叉 Uniswap V2 接口?
- c# - 如何使用 C# 使用 LDAP/OID 连接字符串连接到 Oracle
- python - sklearn-crfsuite - 处理数值/连续特征
- python - 又一个“没有已知父包的尝试相对导入”
- python - 使用张量流计算雅可比和梯度
- amazon-web-services - 如何将 Terraform 状态与现有资源同步?
- python - 如何创建用于在 Python 中显示颜色的类 Canvas?
- mysql - 输入文本数据时出现 ERROR 1064 (42000) 错误
- tensorflow - 切断 TensorFlow Serving 上的输出张量
- ios - React Native 应用中的防篡改措施