How to save Excel binding to Microsoft Word 15.0 object library?

We have a very sophisticated Excel 2010 spreadsheet template. Each new copy of the template must go through several people during its lifetime.

Unfortunately, one of the first people using the template has Office 365 installed. After touching it, the spreadsheet seems to be tied to the Microsoft Word 15.0 object library, which is not available on the Excel 2010 PC. While a separate one is broken the file can be fixed by unchecking the missing library of Word objects in VBA Code Tools> Links, I need to find a way to prevent this from happening in the first place.

I examined the code in detail and cannot find links to the MS Word object library, so what makes Excel bind to it in the first place? Is there anything I can do to prevent this?

+5
source share
2 answers

Unconfirmed, but maybe something like this in your Workbook_BeforeSave event will work:

 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 do not have Office 365 and do not know why it will automatically add a link to Word 15.0; anyway, the above suggests that he does it.

+2
source

To remove, put it inside the module: I know that this will not prevent it in the first place, but it can help 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
source

Source: https://habr.com/ru/post/1215554/


All Articles