Removing References

E

EA

Does anyone know of a way of removing a MISSING reference through code?

The code below me moves are references a reference, but will not work if the
reference is MISSING

EA

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Sub CorrectOutlookReferenceLibrary()

're-references to Outlook 9.0

Dim xObject As Object

On Error Resume Next

Set xObject = ThisWorkbook.VBProject.References.Item("Outlook")

ThisWorkbook.VBProject.References.Remove xObject

ThisWorkbook.VBProject.References.AddFromFile "c:\Program Files\Microsoft
Office\Office\msoutl9.olb"

End Sub
 
E

Executor

Hi EA,

You are close:

Sub CorrectOutlookReferenceLibrary()

're-references to Outlook 9.0

Dim xObject As Object

On Error Resume Next

Set xObject = ThisWorkbook.VBProject.References.Item("Outlook")
ThisWorkbook.VBProject.References.Remove xObject
If Dir("c:\Program Files\Microsoft Office\Office\msoutl9.olb",
vbNormal) <> "" Then
ThisWorkbook.VBProject.References.AddFromFile "c:\Program
Files\Microsoft Office\Office\msoutl9.olb"
End If

End Sub


HTH,

Executor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top