Delete References


Home           Programming       Favorites      

You should first run List Refereences to show your list of references.

After you get your list of references, the following procedure will remove all references except the ones you specifically want to keep.

You should change the names in this procedure to the list of names that was generated with List References.
Sub DeleteReferences()
   Dim VBAEditor As VBIDE.VBE
   Dim VBProj As VBIDE.VBProject

   Set VBAEditor = Application.VBE
   Set VBProj = VBAEditor.ActiveVBProject

   For Each chkRef In VBProj.References
      If Not chkRef.Name = "VBA" Xor _
      chkRef.Name = "WebDesigner" Or _
      chkRef.Name = "stdole" Or _
      chkRef.Name = "Office" Or _
      chkRef.Name = "WebDesignerPage" Or _
      chkRef.Name = "MSFormse" Or _
      chkRef.Name = "DAO" Or _
      chkRef.Name = "WebDesigner_Internal" Or _
      chkRef.Name = "WebDesigner_WebAuthoring" Or _
      chkRef.Name = "WebDesignerPage" Or _
      chkRef.Name = "Excel" Or _
      chkRef.Name = "Word" Or _
      chkRef.Name = "VBIDE" Then

         VBProj.References.Remove chkRef

      End If
   Next

End Sub				

This procedure should work in any Office application.