Results 1 to 4 of 4

Thread: VBE-DLL Error

  1. #1

    VBE-DLL Error

    I have been testing with the following code in Word 97 SR2, and after the msgbox shows, I receive the error: VBE.DLL at 016f:65044040. And then Word shuts down.

    There is the code:

    <pre>Sub Create_Reference()
    '************************************************* ******************************

    Application.VBE.ActiveVBProject.References.AddFrom File _


    Delete_Reference ""

    End Sub

    Sub Delete_Reference(ByVal strFileToDelete As String)

    Dim aRef As Reference
    Dim colRefs As References

    Set colRefs = VBE.ActiveVBProject.References

    For Each aRef In colRefs
    'Debug.Print aRef.Name & "; " & aRef.FullPath & "; " & aRef.Type

    If InStr(1, aRef.FullPath, strFileToDelete, vbTextCompare) > 0 Then
    colRefs.Remove aRef
    End If


    End Sub

    Sub TestThisConnection()


    End Sub


    The code in the last procedure "ThisIsWorking" is calling a procedure which just shows a msgbox.

    Receiving this error code has occurred several times in the past, and I have never been able to figure out what is happening.

    By the way, Create_Reference and Delete_Reference both work from the Intermediate Window.

  2. #2

    Re: VBE-DLL Error

    I may have provided an answer to my own question.

    I added this:

    <pre>Sub GetOutOfThisMess()

    Delete_Reference ""

    End Sub


    To the set while deleting the comparable line in the Create_Reference procedure.



    Don't know. <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

  3. #3
    Super Moderator
    Join Date
    Dec 2000
    New York, NY
    Thanked 29 Times in 27 Posts

    Re: VBE-DLL Error


    I haven't had a chance to try out your code, but wanted to mention that there have been a couple of other posts here with code to remove references (I think by Ron Mittelman and jscher) - so you may want to do a search for those.

    In both cases, if I recall right, the For Each method was avoided and instead, the collection was stepped through - backwards - by a loop counter. There seems to be a general consensus that deleting elements in a collection via For Each leads to bad results as the collection index gets snarfled. (A parallel example is the thread with Chris Greaves regarding deleting bookmarks - note that he's stepped through the collection backwards, one at a time.)


  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Silicon Valley, USA
    Thanked 94 Times in 90 Posts

    Re: VBE-DLL Error

    I think it's very possible that this business of adding references works quite different from creating and destroying normal VB objects. Possibly the object did not even really exist until the procedure ended, or was in some kind of pending state. To test this theory, I changed the Remove line to MsgBox aRef.Name. However, this worked just fine. Who knows? (Note: I am using Office 2000.)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts