IE Automation: Click button (Object invoked has disconnected from clients)

  • I have been trying to load a website and then click a button once it has loaded. Each time .Navigate is completed and its time for it to click the button, I get the error message:
    "Automation error
    The object invoked has disconnected from its clients."


    I have tried this several different ways but can't seem to get it to do anything besides navigate to the website before the error comes


    Here is the code that I used last:


    HTML code of button
    <input name="btnLogin" class="formbutton" onclick="javascript:window.location=noCookieURL('www.Website.com');" type="button" value="Login"/>


    Any help would be be greatly appreciated

  • Re: IE Automation: Click button (Object invoked has disconnected from clients)


    getElementsByName returns an array (collection) of objects - the clue is the plural 's' in 'Elements' - even if there is only one element with the specified name. Therefore try:

    Code
    oIE.Document.getElementsByName("btnLogin")(0).Click

    If that doesn't work tell us the URL.

  • Re: IE Automation: Click button (Object invoked has disconnected from clients)


    Thank you for your help but I won't be able to tell you the website(even though that pretty much kills my chances of help).
    Now I am getting a new error message:
    "The interface is unknown"
    I have searched the web and was unable to find an answer the would fix whatever caused it. Any ideas?


    If you are unable to help due to the limited information I understand and thank you for your time.

  • Re: IE Automation: Click button (Object invoked has disconnected from clients)


    Error message obtained after altering my code to what you have suggested

  • Re: IE Automation: Click button (Object invoked has disconnected from clients)


    I can't give specific help without being able to access the site myself, so I can only offer general help.


    The (0) in my code assumes the element you want to click is the first element with name="btnLogin". Is that correct?


    Add this line before it:

    Code
    MsgBox oIE.document.getElementsByName("btnLogin").Length

    to display the number of elements with the name "btnLogin". If the number is 2 or more, try changing the (0) to (1), or (2), etc.


    If you still get an error with that new line, try stepping through the code by pressing the F8 key and see if you still get the error. It could be that the element you're trying to access is not available when you run the code from start to finish, but by stepping line by line you will introduce an artificial delay which gives time for the element to be available. But all this is guesswork without knowing the URL.

  • Re: IE Automation: Click button (Object invoked has disconnected from clients)


    I have reviewed the code and there is only 1 button with the name "btnLogin". After multiple unsuccessful attempts at altering the code I decided to just try it on a normal website(google.com) It worked perfectly so I can only assume that the issue is with the website. It is a company website so I won't be revealing the code behind it so I believe that this is the end of my journey. Learned quite a bit but just not going to be able to get this working properly.


    Thank you for all your help.

  • Re: IE Automation: Click button (Object invoked has disconnected from clients)


    Does the site use frames? If so, you need to access the document (HTMLDocument) of the specific frame. Something like:

    Code
    Dim HTMLdoc As HTMLDocument  'needs ref to MS HTML Object Library
    Set HTMLdoc = oIE.document.frames("name_of_frame").document   'CHANGE STRING 
    '--- OR ---
    Set HTMLdoc = oIE.document.frames(index_number_of_frame).document   'SPECIFY INDEX

    then use HTMLdoc the same as your code currently uses oIE.document.

  • Re: IE Automation: Click button (Object invoked has disconnected from clients)


    Simply try this:


    1. Internet options
    2. Security
    3. Disable the Security mode
    4. Close IE
    5. Launch IE


    The security mode allow IE to disable the connection to VBA if the call you're doing towards IE is not a standard call, if you call http://www.google.com the security tool let it pass through but a call like https://[someip]/something.php?user=[user]&pw=[pw]&login=submit may be seen like something suspect and the connection between VBA/VBS or whatever created the IE object is deleted.
    The reason is very simple, just imagine for example what you can do if you set the IE visibility to false and you have 1000 machines with a routine which loop a login call to a website, the user doesn't see his own machine is doing something with IE, let's say 5 calls in a seconds, 5x1000=5000 calls every second, what do you thing will happen? :)

  • Re: IE Automation: Click button (Object invoked has disconnected from clients)


    if you still did not find a solution try this after you open the url in ie



    this will again set the instance of the ie into the variable, it happens coz you loose the instance of the internet explorer

  • Re: IE Automation: Click button (Object invoked has disconnected from clients)


    Didnt see i am posting to an old tread sorry guys :0ops:


    any ways i think it will help some one for sure...

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!