We have a very complex Excel 2010 spreadsheet template. Each new copy of the template needs to pass through several people during its lifetime.
我们有一个非常复杂的Excel 2010电子表格模板。模板的每个新副本在其生命周期中需要通过几个人。
Unfortunately, one of the first people to utilize the template has Office 365 installed. After he has touched it, the spreadsheet appears to bind to the Microsoft Word 15.0 Object library, which is not available on the Excel 2010 PCs. While an individual broken file can be fixed by unchecking the missing Word object library in the VBA Code Tools > References, I need to find a way to prevent this from happening in the first place.
不幸的是,第一批使用该模板的人安装了Office 365。触摸后,电子表格似乎绑定到Microsoft Word 15.0对象库,这在Excel 2010 PC上不可用。虽然可以通过在VBA代码工具>引用中取消选中缺少的Word对象库来修复单个损坏的文件,但我需要找到一种方法来防止这种情况首先发生。
I have reviewed the code in detail and I cannot find any reference to the MS Word Object library, so what is causing Excel to bind to it in the first place? Is there anything I can do to prevent it?
我已经详细阅读了代码,但是我找不到对MS Word对象库的任何引用,那么是什么原因导致Excel首先绑定到它?我能做些什么来阻止它吗?
2 个解决方案
#1
2
Untested, but putting something like this in your Workbook_BeforeSave
event would probably work:
未经测试,但在Workbook_BeforeSave事件中放置这样的东西可能会有效:
With ThisWorkbook.VBProject.References
For i = .Count To 1 Step -1
If InStr(.Item(i).Name, "Word") <> 0 Then .Remove .Item(i)
Next
End With
Disclaimer: I don't have Office 365 and don't know why it would automatically add a reference to Word 15.0; anyhow, the above assumes that it does.
免责声明:我没有Office 365,也不知道为什么它会自动添加对Word 15.0的引用;无论如何,上面假设它确实如此。
#2
1
To Remove, place inside module: I know this dosen't prevent it from happening in the first place but this might help to at least remove it before the next person.
要删除,放置在模块内部:我知道这不会阻止它首先发生,但这可能有助于至少在下一个人之前删除它。
Private Sub RemoveRef()
Dim Reference As Object
For Each Reference In ThisWorkbook.VBProject.References
If Reference.Description = "Microsoft Word 15.0 Object library" Then
ThisWorkbook.VBProject.References.Remove Reference
End If
Next
End Sub
#1
2
Untested, but putting something like this in your Workbook_BeforeSave
event would probably work:
未经测试,但在Workbook_BeforeSave事件中放置这样的东西可能会有效:
With ThisWorkbook.VBProject.References
For i = .Count To 1 Step -1
If InStr(.Item(i).Name, "Word") <> 0 Then .Remove .Item(i)
Next
End With
Disclaimer: I don't have Office 365 and don't know why it would automatically add a reference to Word 15.0; anyhow, the above assumes that it does.
免责声明:我没有Office 365,也不知道为什么它会自动添加对Word 15.0的引用;无论如何,上面假设它确实如此。
#2
1
To Remove, place inside module: I know this dosen't prevent it from happening in the first place but this might help to at least remove it before the next person.
要删除,放置在模块内部:我知道这不会阻止它首先发生,但这可能有助于至少在下一个人之前删除它。
Private Sub RemoveRef()
Dim Reference As Object
For Each Reference In ThisWorkbook.VBProject.References
If Reference.Description = "Microsoft Word 15.0 Object library" Then
ThisWorkbook.VBProject.References.Remove Reference
End If
Next
End Sub