Make vba wait till explorer is ready












0















I have a code that pulls down table data from urls.



There I need to make vba to perform a clik action (to unhide last table), which gives back expected result only in debug mode.



Set objCollection = html.getElementsByClassName("{a keyword is entered here}")

objCollection(0).Click


If I simply run the code, it seems like click action was not performed.



If I stop code run right after click command and then let the code again to run, then I get back the expected result.



I have tried many things:




  • DoEvents

  • separate sub ("Refresh_All_Data_Connections") advised in some other topic


where issue was similar



Can somebody help to find the missing code part?










share|improve this question



























    0















    I have a code that pulls down table data from urls.



    There I need to make vba to perform a clik action (to unhide last table), which gives back expected result only in debug mode.



    Set objCollection = html.getElementsByClassName("{a keyword is entered here}")

    objCollection(0).Click


    If I simply run the code, it seems like click action was not performed.



    If I stop code run right after click command and then let the code again to run, then I get back the expected result.



    I have tried many things:




    • DoEvents

    • separate sub ("Refresh_All_Data_Connections") advised in some other topic


    where issue was similar



    Can somebody help to find the missing code part?










    share|improve this question

























      0












      0








      0








      I have a code that pulls down table data from urls.



      There I need to make vba to perform a clik action (to unhide last table), which gives back expected result only in debug mode.



      Set objCollection = html.getElementsByClassName("{a keyword is entered here}")

      objCollection(0).Click


      If I simply run the code, it seems like click action was not performed.



      If I stop code run right after click command and then let the code again to run, then I get back the expected result.



      I have tried many things:




      • DoEvents

      • separate sub ("Refresh_All_Data_Connections") advised in some other topic


      where issue was similar



      Can somebody help to find the missing code part?










      share|improve this question














      I have a code that pulls down table data from urls.



      There I need to make vba to perform a clik action (to unhide last table), which gives back expected result only in debug mode.



      Set objCollection = html.getElementsByClassName("{a keyword is entered here}")

      objCollection(0).Click


      If I simply run the code, it seems like click action was not performed.



      If I stop code run right after click command and then let the code again to run, then I get back the expected result.



      I have tried many things:




      • DoEvents

      • separate sub ("Refresh_All_Data_Connections") advised in some other topic


      where issue was similar



      Can somebody help to find the missing code part?







      internet-explorer refresh wait ready






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 21 '18 at 0:26









      user3920146user3920146

      1




      1
























          1 Answer
          1






          active

          oldest

          votes


















          0














          Try to make a test with code below may help you to solve your issue.






          Sub demo()
          Dim IE As InternetExplorer

          Set IE = CreateObject("InternetExplorer.Application")

          IE.navigate "C:UsersAdministratorDesktopdemo66.html"

          IE.Visible = True

          While IE.Busy
          DoEvents
          Wend
          Do Until IE.readyState = READYSTATE_COMPLETE
          DoEvents
          Loop
          Do Until IE.document.readyState = "complete"
          DoEvents
          Loop

          Set Button = IE.document.getElementById("btn1")
          Button.Click


          End Sub





          You need to change the URL and button ID in above code. Further you can modify the code as per your requirements.



          Also check that scripts are already allowed and IE not showing any prompt to allow it. It can suppress the click.






          share|improve this answer
























          • Thanks, but it still does not work properly. It gives me back data in table that comes up after button click only if I run it in debug (at least button click and the next steps - I place there a breakpoint, press F8, then I can again let it run by pressing F5, so it gets stucked again at the point where I put my breakpoint.

            – user3920146
            Nov 28 '18 at 22:29











          • An other issue just came up regarding my code. It can not be run on my colleagues' desktops. It has some problem with IE object. I have never experienced such an error. If I run same file on my computer it works fine (regardless to this button.click bug)...

            – user3920146
            Nov 28 '18 at 22:43











          • @user3920146, On your colleagues machine. You need to add reference to 'Microsoft HTML Object library' and 'Microsoft Internet Controls'. Than after it can work. If issue persist than try to provide a sample code and detailed error message. We will try to make a test with it and try to provide suggestions to solve it.

            – Deepak-MSFT
            Nov 29 '18 at 5:59











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53403618%2fmake-vba-wait-till-explorer-is-ready%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          Try to make a test with code below may help you to solve your issue.






          Sub demo()
          Dim IE As InternetExplorer

          Set IE = CreateObject("InternetExplorer.Application")

          IE.navigate "C:UsersAdministratorDesktopdemo66.html"

          IE.Visible = True

          While IE.Busy
          DoEvents
          Wend
          Do Until IE.readyState = READYSTATE_COMPLETE
          DoEvents
          Loop
          Do Until IE.document.readyState = "complete"
          DoEvents
          Loop

          Set Button = IE.document.getElementById("btn1")
          Button.Click


          End Sub





          You need to change the URL and button ID in above code. Further you can modify the code as per your requirements.



          Also check that scripts are already allowed and IE not showing any prompt to allow it. It can suppress the click.






          share|improve this answer
























          • Thanks, but it still does not work properly. It gives me back data in table that comes up after button click only if I run it in debug (at least button click and the next steps - I place there a breakpoint, press F8, then I can again let it run by pressing F5, so it gets stucked again at the point where I put my breakpoint.

            – user3920146
            Nov 28 '18 at 22:29











          • An other issue just came up regarding my code. It can not be run on my colleagues' desktops. It has some problem with IE object. I have never experienced such an error. If I run same file on my computer it works fine (regardless to this button.click bug)...

            – user3920146
            Nov 28 '18 at 22:43











          • @user3920146, On your colleagues machine. You need to add reference to 'Microsoft HTML Object library' and 'Microsoft Internet Controls'. Than after it can work. If issue persist than try to provide a sample code and detailed error message. We will try to make a test with it and try to provide suggestions to solve it.

            – Deepak-MSFT
            Nov 29 '18 at 5:59
















          0














          Try to make a test with code below may help you to solve your issue.






          Sub demo()
          Dim IE As InternetExplorer

          Set IE = CreateObject("InternetExplorer.Application")

          IE.navigate "C:UsersAdministratorDesktopdemo66.html"

          IE.Visible = True

          While IE.Busy
          DoEvents
          Wend
          Do Until IE.readyState = READYSTATE_COMPLETE
          DoEvents
          Loop
          Do Until IE.document.readyState = "complete"
          DoEvents
          Loop

          Set Button = IE.document.getElementById("btn1")
          Button.Click


          End Sub





          You need to change the URL and button ID in above code. Further you can modify the code as per your requirements.



          Also check that scripts are already allowed and IE not showing any prompt to allow it. It can suppress the click.






          share|improve this answer
























          • Thanks, but it still does not work properly. It gives me back data in table that comes up after button click only if I run it in debug (at least button click and the next steps - I place there a breakpoint, press F8, then I can again let it run by pressing F5, so it gets stucked again at the point where I put my breakpoint.

            – user3920146
            Nov 28 '18 at 22:29











          • An other issue just came up regarding my code. It can not be run on my colleagues' desktops. It has some problem with IE object. I have never experienced such an error. If I run same file on my computer it works fine (regardless to this button.click bug)...

            – user3920146
            Nov 28 '18 at 22:43











          • @user3920146, On your colleagues machine. You need to add reference to 'Microsoft HTML Object library' and 'Microsoft Internet Controls'. Than after it can work. If issue persist than try to provide a sample code and detailed error message. We will try to make a test with it and try to provide suggestions to solve it.

            – Deepak-MSFT
            Nov 29 '18 at 5:59














          0












          0








          0







          Try to make a test with code below may help you to solve your issue.






          Sub demo()
          Dim IE As InternetExplorer

          Set IE = CreateObject("InternetExplorer.Application")

          IE.navigate "C:UsersAdministratorDesktopdemo66.html"

          IE.Visible = True

          While IE.Busy
          DoEvents
          Wend
          Do Until IE.readyState = READYSTATE_COMPLETE
          DoEvents
          Loop
          Do Until IE.document.readyState = "complete"
          DoEvents
          Loop

          Set Button = IE.document.getElementById("btn1")
          Button.Click


          End Sub





          You need to change the URL and button ID in above code. Further you can modify the code as per your requirements.



          Also check that scripts are already allowed and IE not showing any prompt to allow it. It can suppress the click.






          share|improve this answer













          Try to make a test with code below may help you to solve your issue.






          Sub demo()
          Dim IE As InternetExplorer

          Set IE = CreateObject("InternetExplorer.Application")

          IE.navigate "C:UsersAdministratorDesktopdemo66.html"

          IE.Visible = True

          While IE.Busy
          DoEvents
          Wend
          Do Until IE.readyState = READYSTATE_COMPLETE
          DoEvents
          Loop
          Do Until IE.document.readyState = "complete"
          DoEvents
          Loop

          Set Button = IE.document.getElementById("btn1")
          Button.Click


          End Sub





          You need to change the URL and button ID in above code. Further you can modify the code as per your requirements.



          Also check that scripts are already allowed and IE not showing any prompt to allow it. It can suppress the click.






          Sub demo()
          Dim IE As InternetExplorer

          Set IE = CreateObject("InternetExplorer.Application")

          IE.navigate "C:UsersAdministratorDesktopdemo66.html"

          IE.Visible = True

          While IE.Busy
          DoEvents
          Wend
          Do Until IE.readyState = READYSTATE_COMPLETE
          DoEvents
          Loop
          Do Until IE.document.readyState = "complete"
          DoEvents
          Loop

          Set Button = IE.document.getElementById("btn1")
          Button.Click


          End Sub





          Sub demo()
          Dim IE As InternetExplorer

          Set IE = CreateObject("InternetExplorer.Application")

          IE.navigate "C:UsersAdministratorDesktopdemo66.html"

          IE.Visible = True

          While IE.Busy
          DoEvents
          Wend
          Do Until IE.readyState = READYSTATE_COMPLETE
          DoEvents
          Loop
          Do Until IE.document.readyState = "complete"
          DoEvents
          Loop

          Set Button = IE.document.getElementById("btn1")
          Button.Click


          End Sub






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 22 '18 at 2:26









          Deepak-MSFTDeepak-MSFT

          709116




          709116













          • Thanks, but it still does not work properly. It gives me back data in table that comes up after button click only if I run it in debug (at least button click and the next steps - I place there a breakpoint, press F8, then I can again let it run by pressing F5, so it gets stucked again at the point where I put my breakpoint.

            – user3920146
            Nov 28 '18 at 22:29











          • An other issue just came up regarding my code. It can not be run on my colleagues' desktops. It has some problem with IE object. I have never experienced such an error. If I run same file on my computer it works fine (regardless to this button.click bug)...

            – user3920146
            Nov 28 '18 at 22:43











          • @user3920146, On your colleagues machine. You need to add reference to 'Microsoft HTML Object library' and 'Microsoft Internet Controls'. Than after it can work. If issue persist than try to provide a sample code and detailed error message. We will try to make a test with it and try to provide suggestions to solve it.

            – Deepak-MSFT
            Nov 29 '18 at 5:59



















          • Thanks, but it still does not work properly. It gives me back data in table that comes up after button click only if I run it in debug (at least button click and the next steps - I place there a breakpoint, press F8, then I can again let it run by pressing F5, so it gets stucked again at the point where I put my breakpoint.

            – user3920146
            Nov 28 '18 at 22:29











          • An other issue just came up regarding my code. It can not be run on my colleagues' desktops. It has some problem with IE object. I have never experienced such an error. If I run same file on my computer it works fine (regardless to this button.click bug)...

            – user3920146
            Nov 28 '18 at 22:43











          • @user3920146, On your colleagues machine. You need to add reference to 'Microsoft HTML Object library' and 'Microsoft Internet Controls'. Than after it can work. If issue persist than try to provide a sample code and detailed error message. We will try to make a test with it and try to provide suggestions to solve it.

            – Deepak-MSFT
            Nov 29 '18 at 5:59

















          Thanks, but it still does not work properly. It gives me back data in table that comes up after button click only if I run it in debug (at least button click and the next steps - I place there a breakpoint, press F8, then I can again let it run by pressing F5, so it gets stucked again at the point where I put my breakpoint.

          – user3920146
          Nov 28 '18 at 22:29





          Thanks, but it still does not work properly. It gives me back data in table that comes up after button click only if I run it in debug (at least button click and the next steps - I place there a breakpoint, press F8, then I can again let it run by pressing F5, so it gets stucked again at the point where I put my breakpoint.

          – user3920146
          Nov 28 '18 at 22:29













          An other issue just came up regarding my code. It can not be run on my colleagues' desktops. It has some problem with IE object. I have never experienced such an error. If I run same file on my computer it works fine (regardless to this button.click bug)...

          – user3920146
          Nov 28 '18 at 22:43





          An other issue just came up regarding my code. It can not be run on my colleagues' desktops. It has some problem with IE object. I have never experienced such an error. If I run same file on my computer it works fine (regardless to this button.click bug)...

          – user3920146
          Nov 28 '18 at 22:43













          @user3920146, On your colleagues machine. You need to add reference to 'Microsoft HTML Object library' and 'Microsoft Internet Controls'. Than after it can work. If issue persist than try to provide a sample code and detailed error message. We will try to make a test with it and try to provide suggestions to solve it.

          – Deepak-MSFT
          Nov 29 '18 at 5:59





          @user3920146, On your colleagues machine. You need to add reference to 'Microsoft HTML Object library' and 'Microsoft Internet Controls'. Than after it can work. If issue persist than try to provide a sample code and detailed error message. We will try to make a test with it and try to provide suggestions to solve it.

          – Deepak-MSFT
          Nov 29 '18 at 5:59


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53403618%2fmake-vba-wait-till-explorer-is-ready%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          MongoDB - Not Authorized To Execute Command

          in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith

          Npm cannot find a required file even through it is in the searched directory