Remove a Reference

S

scott

Code 1 adds the ADO 2.6 Library fine. Can someone tell me how code 2 should
read to remove the ADO 2.6 Library? I found CODE 2 as example on web, but
wasn't sure how it could be changed.

CODE 1
Application.VBE.ActiveVBProject.References.AddFromFile _
"C:\Program Files\Common Files\System\ado\msado26.tlb"

CODE 2
Set x = Application.VBE.ActiveVBProject _
.References.Item("Project2")

Application.VBE.ActiveVBProject.References.Remove x
 
R

Rob Bovey

scott said:
Code 1 adds the ADO 2.6 Library fine. Can someone tell me how code 2
should read to remove the ADO 2.6 Library? I found CODE 2 as example on
web, but wasn't sure how it could be changed.
CODE 1
Application.VBE.ActiveVBProject.References.AddFromFile _
"C:\Program Files\Common Files\System\ado\msado26.tlb"
CODE 2
Set x = Application.VBE.ActiveVBProject _
.References.Item("Project2")
Application.VBE.ActiveVBProject.References.Remove x

Hi Scott,

Here's one way to do it:

Sub RemoveReference()
Dim x As Object
Set x = Application.VBE.ActiveVBProject _
.References.Item("ADODB")
Application.VBE.ActiveVBProject.References.Remove x
End Sub

--
Rob Bovey, Excel MVP
Application Professionals
http://www.appspro.com/

* Take your Excel development skills to the next level.
* Professional Excel Development
http://www.appspro.com/Books/Books.htm
 

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