Results 1 to 3 of 3

Thread: Cannot dispose an object!!?!?!?!

  1. #1

    Thread Starter
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538

    Unhappy Cannot dispose an object!!?!?!?!

    I'm using a 3rd party API (in this case Quality Center OTA incase its of interest) in an Excel VBA project, and creating an object from it (TDAPIOLELib.tdconnection, which is a class, retuning an object in the documentation).

    I use a "If not (thisObject is nothing) Then" statement, before running some cleanup code. At this point, the code inside of this IF statement is correctly executed & "thisObject" is not nothing.

    The end of this IF block, I try to use "Set thisObject = nothing" (at this point, in a watch window I can see a whole bunch of "not connected"-type statements against each of the object's properties, however the object still very much exists (I've tried a "?Connection is nothing" call in the immediate window and successfully got a "False" value returned).

    As soon as this line is executed, I get a runtime error 438, object doesn't support this property or method! Little confused here and the last thing I want is to have any memory leaks or non-disposed objects floating around having been caused by my macro/code. Help please/any suggestions/explainations?

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Cannot dispose an object!!?!?!?!

    how are you creating the object?
    you will probably need to post your code
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538

    Thumbs up [Fixed] Cannot dispose an object!!?!?!?!

    What a silly mistake! Thanks westconn1, pointed me in the right direction there. Just found the Connection "object" I was trying to set to nothing was a property get only, & that the actual object, a class-level variable was the one I was after (m_Connection instead).

    Thanks for the tip!

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

Posting Permissions

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



Click Here to Expand Forum to Full Width