The object invoked has disconnected from its clients Vbscript and internet explorer



Here was a vbscript that was working well and all of a sudden started throwing this vague error - "the object invoked has disconnected from its clients"

After a lot of research here is what I found that might save your day:

Find the handle of the window and re-associate the object with the handle. (This is what will reconnect your ie client back to the object"
Here is the code:

Set ie = WScript.CreateObject("InternetExplorer.Application")
With ie

     hwnd = .hwnd
     .Navigate "http://xyz.com"
End With

Set oShell = CreateObject("Shell.Application")

For Each Wnd In oShell.Windows
       If hwnd = Wnd.hwnd Then Set ie = Wnd
Next

  Happy Coding :)

Comments

  1. Anonymous25/6/13

    Just want to say your article is as surprising. The clearness on your publish is simply nice and that
    i can think you are knowledgeable on this subject. Fine
    together with your permission let me to clutch your RSS feed to stay updated with drawing close post.
    Thanks a million and please keep up the enjoyable work.



    Also visit my blog post; Shower Head Filter

    ReplyDelete
  2. Anonymous17/1/14

    Thank you very much. This was just what I needed when I needed it.

    ReplyDelete
    Replies
    1. Thanks , Glad that helped!

      Best Regards,
      Ady.

      Delete
  3. Anonymous8/2/14

    Excellent, solves vba CreateObject("InternetExplorer.Application") "The object invoked has disconnected from its clients" ... haven't found the cause yet, but this allows a workaround

    ReplyDelete
    Replies
    1. That's the best thing when someone else can benefit what you found way back! Glad it worked for you...

      Delete
  4. Anonymous12/5/14

    Wow! - Thank You.

    ReplyDelete
  5. Anonymous11/6/14

    Thank you

    ReplyDelete
  6. Anonymous17/1/15

    Excellent. In my application I need to run through the loop to search for the window each time before I use the ie object. Odd thing is that on other machines I don't! Thanks very much.

    ReplyDelete
    Replies
    1. I am glad this worked for you!

      Cheers,
      Ady

      Delete
  7. Anonymous13/6/15

    Turning UAC off or running the script from elevated command prompt (Run as Administrator) solves the isue too. But your solution is better.

    ReplyDelete
  8. Anonymous17/6/15

    Thank you sooooooooooo much, that solution really work out :)

    ReplyDelete
    Replies
    1. It's always good to see when things that worked for me in the past works for others!

      Delete
  9. Anonymous25/4/17

    I was using Set IE = New InternetExplorerMedium as most people recommended and it was working fine and all of a sudden I had this awful "disconnected" error that was driving me nuts! However, I've tried your method CreateObject("InternetExplorer.Application") and it finally worked!! The issue was with the creation method I guess. Thank you Thank you Thank you Thank you you've saved me hours of going nuts!!! :-)

    ReplyDelete
    Replies
    1. It's always cool when an old blog post still holds good.
      Cheers,
      Ady

      Delete
  10. PERFECT SOLUTION :)

    ReplyDelete
  11. Anonymous15/5/22

    Website louis vuitton replica click to investigate luxury replica bags go right here best replica bags

    ReplyDelete

Post a Comment

Popular posts from this blog

Software Testing @ Microsoft

Trim / Remove spaces in Xpath?