IRish3538
12-17-2012, 01:52 PM
Hi all,
I've scoured the site looking for an answer but now I'm admitting defeat. I have an excel workbook with a ton of VBA in it that required a Word reference library. All was fine until my office started migrating from Windows XP to Windows 7.. which carry different versions of office. I'm trying to load the MSWord Reference Library on the fly (which I can do) and delete out the missing library if one exists (which isn't going so well)... Here's what I have that isn't working.. I get a run-time error that says "Error in Loading DLL" on the ".isbroken" line.
Sub word_ref()
Dim theRef As Variant, i As Long
'On Error Resume Next
'Remove any missing reference libraries
For i = ThisWorkbook.VBProject.References.count To 1 Step -1
Set theRef = ThisWorkbook.VBProject.References.Item(i)
If theRef.isbroken = True Then
ThisWorkbook.VBProject.References.Remove theRef
ThisWorkbook.VBProject.References.AddFromFile _
Application.Path & "\MSWORD.olb"
End If
Next i
End Sub
I've scoured the site looking for an answer but now I'm admitting defeat. I have an excel workbook with a ton of VBA in it that required a Word reference library. All was fine until my office started migrating from Windows XP to Windows 7.. which carry different versions of office. I'm trying to load the MSWord Reference Library on the fly (which I can do) and delete out the missing library if one exists (which isn't going so well)... Here's what I have that isn't working.. I get a run-time error that says "Error in Loading DLL" on the ".isbroken" line.
Sub word_ref()
Dim theRef As Variant, i As Long
'On Error Resume Next
'Remove any missing reference libraries
For i = ThisWorkbook.VBProject.References.count To 1 Step -1
Set theRef = ThisWorkbook.VBProject.References.Item(i)
If theRef.isbroken = True Then
ThisWorkbook.VBProject.References.Remove theRef
ThisWorkbook.VBProject.References.AddFromFile _
Application.Path & "\MSWORD.olb"
End If
Next i
End Sub