Error automating website data entry as the website is still loadingUploading to the Web with VBAHow to use querySelector to click a button by <a title=“”> in VBALet the user click on the cells as their input for an Excel InputBox using VBAVBA Lookup - Unable to get the Vlookup property of the WorkSheet function classExcel VBA to search for up to 15 values in one searchSyntax / Loop ErrorsInserting text in a embedded Word template, at a bookmark, from excel. “error 13 Type mismatch” errorBetter way of copy and pasting valuesNew to VBA having checkbox problemsError on automating data entryHow to loop cell values from excel into a websites text box with VBA?VBA for Autocomplete ComboBox from another closed workbook

Why colon to denote that a value belongs to a type?

What is the most important source of natural gas? coal, oil or other?

Geological aftereffects of an asteroid impact on a large mountain range?

When did God say "let all the angels of God worship him" as stated in Hebrews 1:6?

Integrating an absolute function using Mathematica

Logarithm of dependent variable is uniformly distributed. How to calculate a confidence interval for the mean?

LASSO Regression - p-values and coefficients

Are there situations when self-assignment is useful?

Does this degree 12 genus 1 curve have only one point over infinitely many finite fields?

How can I find where certain bash function is defined?

Where is the encrypted mask value?

How bitcoin nodes update UTXO set when their latests blocks are replaced?

What is the 中 in ダウンロード中?

ESTA/WVP - leaving US within 90 days, then staying in DR

How to convert to standalone document a matrix table

Can you heal a summoned creature?

Tic-tac-toe for the terminal, written in C

Is there a public standard for 8 and 10 character grid locators?

When and what was the first 3D acceleration device ever released?

analysis of BJT PNP type - why they can use voltage divider?

Rename photos to match video titles

Apparent Ring of Craters on the Moon

Where is the logic in castrating fighters?

How can I translate "would" in "He had to run faster than his tribemate, as the hindmost would be eaten by the lion"?



Error automating website data entry as the website is still loading


Uploading to the Web with VBAHow to use querySelector to click a button by <a title=“”> in VBALet the user click on the cells as their input for an Excel InputBox using VBAVBA Lookup - Unable to get the Vlookup property of the WorkSheet function classExcel VBA to search for up to 15 values in one searchSyntax / Loop ErrorsInserting text in a embedded Word template, at a bookmark, from excel. “error 13 Type mismatch” errorBetter way of copy and pasting valuesNew to VBA having checkbox problemsError on automating data entryHow to loop cell values from excel into a websites text box with VBA?VBA for Autocomplete ComboBox from another closed workbook






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















I have code which picks up data from multiple columns from ThisWorkbook and puts in various field in website in internet explorer. The website loads after clicking on line1 (Search button). Then the code throws an error at line2 where it clicks on checkbox, as there is no checkbox yet if the website is still loading. (I think the website is built on Sharepoint and is poorly coded.)



Is there any code which repeats line 2 after 2-3 seconds and continues further whenever the error appears? I tried error handler to repeat the code but didn't work.



 Sub CSA_Upload()

Dim test1 As Long, test2 As Long
test1 = Timer

Dim n As Long
Range("A1").Select
n = Selection.End(xlDown).Row
ThisWorkbook.Sheets("Data").Range("A2:A" & n).Interior.ColorIndex = 0

Dim IE As Object
Dim doc As Object
Dim htmlTable As htmlTable
Set IE = New InternetExplorerMedium
'Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True

'Navigate to CSA tool Home Page
IE.navigate "https://csa.abcdefg.com/Collector_view.aspx/"

'Wait till it loads
Do While IE.Busy
Application.Wait DateAdd("s", 1, Now)
Loop

Set doc = CreateObject("htmlfile")
Set doc = IE.document

'Enter Invoice Number in SearchBy box
doc.getElementById("ContentPlaceHolder1_ddlSearch").Value = "[Inv Number]"

Range("A1").Select

'Count the number of rows in the data list
Dim X As Long
Range("A1").Select
X = Selection.End(xlDown).Row

'For each invoice number the loop starts here
For rowNo = 2 To X
ActiveCell.Offset(1).Select
'Fill Blue colour in active processing invoice number cell
ThisWorkbook.Sheets("Data").Range("A" & rowNo).Interior.ColorIndex = 37

'Input the invoice number
doc.getElementById("ContentPlaceHolder1_txtSearch").Value = ThisWorkbook.Sheets("Data").Range("A" & rowNo).Value

'Click the Search button
'This is the Line1
doc.getElementById("ContentPlaceHolder1_search").Click

'Wait till it loads
Do While IE.Busy
Application.Wait DateAdd("s", 5, Now)
Loop

'Checkbox select all
'This is the Line2
doc.getElementById("ContentPlaceHolder1_GridView1_chkboxSelectAll").Click
'Wait 3 seconds till it selects all the checkboxes
Application.Wait DateAdd("s", 3, Now)

'Enter rest of the data
doc.getElementById("ContentPlaceHolder1_ddlaction").Value = ThisWorkbook.Sheets("Data").Range("B" & rowNo).Value 'Input Action
doc.getElementById("ContentPlaceHolder1_txtToDoDate").Value = ThisWorkbook.Sheets("Data").Range("C" & rowNo).Value 'Input Action Date
doc.getElementById("ContentPlaceHolder1_ddlstatus").Value = ThisWorkbook.Sheets("Data").Range("D" & rowNo).Value 'Input Root Cause
doc.getElementById("ContentPlaceHolder1_txtcomments").Value = ThisWorkbook.Sheets("Data").Range("E" & rowNo).Value 'Input Comments
doc.getElementById("ContentPlaceHolder1_btn_Comments").Click 'Click Submit button

Application.Wait DateAdd("s", 3, Now)

'Hit enter on MessegeBox
Application.SendKeys "ENTER"

'Fill Green colour in the active cell when all entries are passed
ThisWorkbook.Sheets("Data").Range("A" & rowNo).Interior.ColorIndex = 35

Next 'Proceed to next invoice number

IE.Quit 'Quit Internet explorer
test2 = Timer
MsgBox (X - 1) & " Invoices have been updated and it took " & Format((test2 - test1) / 86400, "hh:mm:ss") & " Seconds."

End Sub









share|improve this question






























    1















    I have code which picks up data from multiple columns from ThisWorkbook and puts in various field in website in internet explorer. The website loads after clicking on line1 (Search button). Then the code throws an error at line2 where it clicks on checkbox, as there is no checkbox yet if the website is still loading. (I think the website is built on Sharepoint and is poorly coded.)



    Is there any code which repeats line 2 after 2-3 seconds and continues further whenever the error appears? I tried error handler to repeat the code but didn't work.



     Sub CSA_Upload()

    Dim test1 As Long, test2 As Long
    test1 = Timer

    Dim n As Long
    Range("A1").Select
    n = Selection.End(xlDown).Row
    ThisWorkbook.Sheets("Data").Range("A2:A" & n).Interior.ColorIndex = 0

    Dim IE As Object
    Dim doc As Object
    Dim htmlTable As htmlTable
    Set IE = New InternetExplorerMedium
    'Set IE = CreateObject("InternetExplorer.Application")
    IE.Visible = True

    'Navigate to CSA tool Home Page
    IE.navigate "https://csa.abcdefg.com/Collector_view.aspx/"

    'Wait till it loads
    Do While IE.Busy
    Application.Wait DateAdd("s", 1, Now)
    Loop

    Set doc = CreateObject("htmlfile")
    Set doc = IE.document

    'Enter Invoice Number in SearchBy box
    doc.getElementById("ContentPlaceHolder1_ddlSearch").Value = "[Inv Number]"

    Range("A1").Select

    'Count the number of rows in the data list
    Dim X As Long
    Range("A1").Select
    X = Selection.End(xlDown).Row

    'For each invoice number the loop starts here
    For rowNo = 2 To X
    ActiveCell.Offset(1).Select
    'Fill Blue colour in active processing invoice number cell
    ThisWorkbook.Sheets("Data").Range("A" & rowNo).Interior.ColorIndex = 37

    'Input the invoice number
    doc.getElementById("ContentPlaceHolder1_txtSearch").Value = ThisWorkbook.Sheets("Data").Range("A" & rowNo).Value

    'Click the Search button
    'This is the Line1
    doc.getElementById("ContentPlaceHolder1_search").Click

    'Wait till it loads
    Do While IE.Busy
    Application.Wait DateAdd("s", 5, Now)
    Loop

    'Checkbox select all
    'This is the Line2
    doc.getElementById("ContentPlaceHolder1_GridView1_chkboxSelectAll").Click
    'Wait 3 seconds till it selects all the checkboxes
    Application.Wait DateAdd("s", 3, Now)

    'Enter rest of the data
    doc.getElementById("ContentPlaceHolder1_ddlaction").Value = ThisWorkbook.Sheets("Data").Range("B" & rowNo).Value 'Input Action
    doc.getElementById("ContentPlaceHolder1_txtToDoDate").Value = ThisWorkbook.Sheets("Data").Range("C" & rowNo).Value 'Input Action Date
    doc.getElementById("ContentPlaceHolder1_ddlstatus").Value = ThisWorkbook.Sheets("Data").Range("D" & rowNo).Value 'Input Root Cause
    doc.getElementById("ContentPlaceHolder1_txtcomments").Value = ThisWorkbook.Sheets("Data").Range("E" & rowNo).Value 'Input Comments
    doc.getElementById("ContentPlaceHolder1_btn_Comments").Click 'Click Submit button

    Application.Wait DateAdd("s", 3, Now)

    'Hit enter on MessegeBox
    Application.SendKeys "ENTER"

    'Fill Green colour in the active cell when all entries are passed
    ThisWorkbook.Sheets("Data").Range("A" & rowNo).Interior.ColorIndex = 35

    Next 'Proceed to next invoice number

    IE.Quit 'Quit Internet explorer
    test2 = Timer
    MsgBox (X - 1) & " Invoices have been updated and it took " & Format((test2 - test1) / 86400, "hh:mm:ss") & " Seconds."

    End Sub









    share|improve this question


























      1












      1








      1








      I have code which picks up data from multiple columns from ThisWorkbook and puts in various field in website in internet explorer. The website loads after clicking on line1 (Search button). Then the code throws an error at line2 where it clicks on checkbox, as there is no checkbox yet if the website is still loading. (I think the website is built on Sharepoint and is poorly coded.)



      Is there any code which repeats line 2 after 2-3 seconds and continues further whenever the error appears? I tried error handler to repeat the code but didn't work.



       Sub CSA_Upload()

      Dim test1 As Long, test2 As Long
      test1 = Timer

      Dim n As Long
      Range("A1").Select
      n = Selection.End(xlDown).Row
      ThisWorkbook.Sheets("Data").Range("A2:A" & n).Interior.ColorIndex = 0

      Dim IE As Object
      Dim doc As Object
      Dim htmlTable As htmlTable
      Set IE = New InternetExplorerMedium
      'Set IE = CreateObject("InternetExplorer.Application")
      IE.Visible = True

      'Navigate to CSA tool Home Page
      IE.navigate "https://csa.abcdefg.com/Collector_view.aspx/"

      'Wait till it loads
      Do While IE.Busy
      Application.Wait DateAdd("s", 1, Now)
      Loop

      Set doc = CreateObject("htmlfile")
      Set doc = IE.document

      'Enter Invoice Number in SearchBy box
      doc.getElementById("ContentPlaceHolder1_ddlSearch").Value = "[Inv Number]"

      Range("A1").Select

      'Count the number of rows in the data list
      Dim X As Long
      Range("A1").Select
      X = Selection.End(xlDown).Row

      'For each invoice number the loop starts here
      For rowNo = 2 To X
      ActiveCell.Offset(1).Select
      'Fill Blue colour in active processing invoice number cell
      ThisWorkbook.Sheets("Data").Range("A" & rowNo).Interior.ColorIndex = 37

      'Input the invoice number
      doc.getElementById("ContentPlaceHolder1_txtSearch").Value = ThisWorkbook.Sheets("Data").Range("A" & rowNo).Value

      'Click the Search button
      'This is the Line1
      doc.getElementById("ContentPlaceHolder1_search").Click

      'Wait till it loads
      Do While IE.Busy
      Application.Wait DateAdd("s", 5, Now)
      Loop

      'Checkbox select all
      'This is the Line2
      doc.getElementById("ContentPlaceHolder1_GridView1_chkboxSelectAll").Click
      'Wait 3 seconds till it selects all the checkboxes
      Application.Wait DateAdd("s", 3, Now)

      'Enter rest of the data
      doc.getElementById("ContentPlaceHolder1_ddlaction").Value = ThisWorkbook.Sheets("Data").Range("B" & rowNo).Value 'Input Action
      doc.getElementById("ContentPlaceHolder1_txtToDoDate").Value = ThisWorkbook.Sheets("Data").Range("C" & rowNo).Value 'Input Action Date
      doc.getElementById("ContentPlaceHolder1_ddlstatus").Value = ThisWorkbook.Sheets("Data").Range("D" & rowNo).Value 'Input Root Cause
      doc.getElementById("ContentPlaceHolder1_txtcomments").Value = ThisWorkbook.Sheets("Data").Range("E" & rowNo).Value 'Input Comments
      doc.getElementById("ContentPlaceHolder1_btn_Comments").Click 'Click Submit button

      Application.Wait DateAdd("s", 3, Now)

      'Hit enter on MessegeBox
      Application.SendKeys "ENTER"

      'Fill Green colour in the active cell when all entries are passed
      ThisWorkbook.Sheets("Data").Range("A" & rowNo).Interior.ColorIndex = 35

      Next 'Proceed to next invoice number

      IE.Quit 'Quit Internet explorer
      test2 = Timer
      MsgBox (X - 1) & " Invoices have been updated and it took " & Format((test2 - test1) / 86400, "hh:mm:ss") & " Seconds."

      End Sub









      share|improve this question
















      I have code which picks up data from multiple columns from ThisWorkbook and puts in various field in website in internet explorer. The website loads after clicking on line1 (Search button). Then the code throws an error at line2 where it clicks on checkbox, as there is no checkbox yet if the website is still loading. (I think the website is built on Sharepoint and is poorly coded.)



      Is there any code which repeats line 2 after 2-3 seconds and continues further whenever the error appears? I tried error handler to repeat the code but didn't work.



       Sub CSA_Upload()

      Dim test1 As Long, test2 As Long
      test1 = Timer

      Dim n As Long
      Range("A1").Select
      n = Selection.End(xlDown).Row
      ThisWorkbook.Sheets("Data").Range("A2:A" & n).Interior.ColorIndex = 0

      Dim IE As Object
      Dim doc As Object
      Dim htmlTable As htmlTable
      Set IE = New InternetExplorerMedium
      'Set IE = CreateObject("InternetExplorer.Application")
      IE.Visible = True

      'Navigate to CSA tool Home Page
      IE.navigate "https://csa.abcdefg.com/Collector_view.aspx/"

      'Wait till it loads
      Do While IE.Busy
      Application.Wait DateAdd("s", 1, Now)
      Loop

      Set doc = CreateObject("htmlfile")
      Set doc = IE.document

      'Enter Invoice Number in SearchBy box
      doc.getElementById("ContentPlaceHolder1_ddlSearch").Value = "[Inv Number]"

      Range("A1").Select

      'Count the number of rows in the data list
      Dim X As Long
      Range("A1").Select
      X = Selection.End(xlDown).Row

      'For each invoice number the loop starts here
      For rowNo = 2 To X
      ActiveCell.Offset(1).Select
      'Fill Blue colour in active processing invoice number cell
      ThisWorkbook.Sheets("Data").Range("A" & rowNo).Interior.ColorIndex = 37

      'Input the invoice number
      doc.getElementById("ContentPlaceHolder1_txtSearch").Value = ThisWorkbook.Sheets("Data").Range("A" & rowNo).Value

      'Click the Search button
      'This is the Line1
      doc.getElementById("ContentPlaceHolder1_search").Click

      'Wait till it loads
      Do While IE.Busy
      Application.Wait DateAdd("s", 5, Now)
      Loop

      'Checkbox select all
      'This is the Line2
      doc.getElementById("ContentPlaceHolder1_GridView1_chkboxSelectAll").Click
      'Wait 3 seconds till it selects all the checkboxes
      Application.Wait DateAdd("s", 3, Now)

      'Enter rest of the data
      doc.getElementById("ContentPlaceHolder1_ddlaction").Value = ThisWorkbook.Sheets("Data").Range("B" & rowNo).Value 'Input Action
      doc.getElementById("ContentPlaceHolder1_txtToDoDate").Value = ThisWorkbook.Sheets("Data").Range("C" & rowNo).Value 'Input Action Date
      doc.getElementById("ContentPlaceHolder1_ddlstatus").Value = ThisWorkbook.Sheets("Data").Range("D" & rowNo).Value 'Input Root Cause
      doc.getElementById("ContentPlaceHolder1_txtcomments").Value = ThisWorkbook.Sheets("Data").Range("E" & rowNo).Value 'Input Comments
      doc.getElementById("ContentPlaceHolder1_btn_Comments").Click 'Click Submit button

      Application.Wait DateAdd("s", 3, Now)

      'Hit enter on MessegeBox
      Application.SendKeys "ENTER"

      'Fill Green colour in the active cell when all entries are passed
      ThisWorkbook.Sheets("Data").Range("A" & rowNo).Interior.ColorIndex = 35

      Next 'Proceed to next invoice number

      IE.Quit 'Quit Internet explorer
      test2 = Timer
      MsgBox (X - 1) & " Invoices have been updated and it took " & Format((test2 - test1) / 86400, "hh:mm:ss") & " Seconds."

      End Sub






      excel vba web-scraping






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 25 at 8:56









      QHarr

      43.4k82448




      43.4k82448










      asked Mar 24 at 7:07









      Prateek VishwasPrateek Vishwas

      7118




      7118






















          3 Answers
          3






          active

          oldest

          votes


















          0














          revised on 2019-03-25



          I think the error is thrown because the doc is changed.



          Rewrite



          ' This is the Line2
          doc.getElementById("ContentPlaceHolder1_GridView1_chkboxSelectAll").Click
          'Wait 3 seconds till it selects all the checkboxes
          Application.Wait DateAdd("s", 3, Now)


          as



          ' This is the Line2 
          application.wait Application.Wait DateAdd("s", 1, Now)
          set doc = IE.document
          doc.getElementById("ContentPlaceHolder1_GridView1_chkboxSelectAll").Click
          'Wait 3 seconds till it selects all the checkboxes
          Application.Wait DateAdd("s", 3, Now)


          maybe helpful.






          share|improve this answer

























          • I don't see doc been changed! However, I tried your suggestion and It's still throwing error 'Run-Time error '424' Object Required. It's not with all the rows. It works for for couple of line smoothly and then randomly the error appears. As I said the cause might be due to executing the code before the page is loaded completely. Is it possible to run doc.getElementById("ContentPlaceHolder1_GridView1_chkboxSelectAll").Click after few seconds (2 or 3) again when this error appears?

            – Prateek Vishwas
            Mar 24 at 16:05












          • When the error routes me to debug screen and I run the same highlighted line, It proceeds further without any error.

            – Prateek Vishwas
            Mar 24 at 16:11












          • I revised my answer. application.wait dateadd("s",1,now) is added to wait for one second.

            – PaichengWu
            Mar 25 at 0:39











          • Sorry @PaichengWu it still doesn't work. I had to delay the line 2 code by fixed time 10 seconds and now it's not giving me any error. I understand this is not a fix and the code will throw an error again if the website loads for more than 10 seconds but for all my tests the page is being loaded within 5-8 seconds.

            – Prateek Vishwas
            Mar 25 at 14:10


















          0














          Use proper page load waits after each .Navigate and .Click.



          While ie.Busy Or ie.readyState < 4: DoEvents: Wend


          Also, you can wrap elements that are throwing errors, related to timings, in timed loops which attempt to set the object reference



          Dim t As Date, ele As Object
          Const MAX_WAIT_SEC As Long = 10

          t = Timer
          Do
          On Error Resume Next
          Set ele = doc.getElementById("ContentPlaceHolder1_GridView1_chkboxSelectAll")
          On Error GoTo 0
          If Timer - t > MAX_WAIT_SEC Then Exit Do
          Loop While ele Is Nothing

          If Not ele Is Nothing Then
          ele.Click
          End If





          share|improve this answer






























            0














            I have removed below wait loop after line 1.



             'Wait till it loads
            Do While IE.Busy
            Application.Wait DateAdd("s", 5, Now)
            Loop


            and added fix 10 seconds wait time Application.Wait DateAdd("s", 10, Now) just before



             doc.getElementById("ContentPlaceHolder1_GridView1_chkboxSelectAll").Click
            'Wait 3 seconds till it selects all the checkboxes
            Application.Wait DateAdd("s", 3, Now)


            So the final piece of code is as below and it's working!



            'This is the Line1
            doc.getElementById("ContentPlaceHolder1_search").Click

            'Checkbox select all
            'This is the Line2
            Application.Wait DateAdd("s", 10, Now)
            doc.getElementById("ContentPlaceHolder1_GridView1_chkboxSelectAll").Click
            'Wait 3 seconds till it selects all the checkboxes
            Application.Wait DateAdd("s", 3, Now)





            share|improve this answer























              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%2f55321474%2ferror-automating-website-data-entry-as-the-website-is-still-loading%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              3 Answers
              3






              active

              oldest

              votes








              3 Answers
              3






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              0














              revised on 2019-03-25



              I think the error is thrown because the doc is changed.



              Rewrite



              ' This is the Line2
              doc.getElementById("ContentPlaceHolder1_GridView1_chkboxSelectAll").Click
              'Wait 3 seconds till it selects all the checkboxes
              Application.Wait DateAdd("s", 3, Now)


              as



              ' This is the Line2 
              application.wait Application.Wait DateAdd("s", 1, Now)
              set doc = IE.document
              doc.getElementById("ContentPlaceHolder1_GridView1_chkboxSelectAll").Click
              'Wait 3 seconds till it selects all the checkboxes
              Application.Wait DateAdd("s", 3, Now)


              maybe helpful.






              share|improve this answer

























              • I don't see doc been changed! However, I tried your suggestion and It's still throwing error 'Run-Time error '424' Object Required. It's not with all the rows. It works for for couple of line smoothly and then randomly the error appears. As I said the cause might be due to executing the code before the page is loaded completely. Is it possible to run doc.getElementById("ContentPlaceHolder1_GridView1_chkboxSelectAll").Click after few seconds (2 or 3) again when this error appears?

                – Prateek Vishwas
                Mar 24 at 16:05












              • When the error routes me to debug screen and I run the same highlighted line, It proceeds further without any error.

                – Prateek Vishwas
                Mar 24 at 16:11












              • I revised my answer. application.wait dateadd("s",1,now) is added to wait for one second.

                – PaichengWu
                Mar 25 at 0:39











              • Sorry @PaichengWu it still doesn't work. I had to delay the line 2 code by fixed time 10 seconds and now it's not giving me any error. I understand this is not a fix and the code will throw an error again if the website loads for more than 10 seconds but for all my tests the page is being loaded within 5-8 seconds.

                – Prateek Vishwas
                Mar 25 at 14:10















              0














              revised on 2019-03-25



              I think the error is thrown because the doc is changed.



              Rewrite



              ' This is the Line2
              doc.getElementById("ContentPlaceHolder1_GridView1_chkboxSelectAll").Click
              'Wait 3 seconds till it selects all the checkboxes
              Application.Wait DateAdd("s", 3, Now)


              as



              ' This is the Line2 
              application.wait Application.Wait DateAdd("s", 1, Now)
              set doc = IE.document
              doc.getElementById("ContentPlaceHolder1_GridView1_chkboxSelectAll").Click
              'Wait 3 seconds till it selects all the checkboxes
              Application.Wait DateAdd("s", 3, Now)


              maybe helpful.






              share|improve this answer

























              • I don't see doc been changed! However, I tried your suggestion and It's still throwing error 'Run-Time error '424' Object Required. It's not with all the rows. It works for for couple of line smoothly and then randomly the error appears. As I said the cause might be due to executing the code before the page is loaded completely. Is it possible to run doc.getElementById("ContentPlaceHolder1_GridView1_chkboxSelectAll").Click after few seconds (2 or 3) again when this error appears?

                – Prateek Vishwas
                Mar 24 at 16:05












              • When the error routes me to debug screen and I run the same highlighted line, It proceeds further without any error.

                – Prateek Vishwas
                Mar 24 at 16:11












              • I revised my answer. application.wait dateadd("s",1,now) is added to wait for one second.

                – PaichengWu
                Mar 25 at 0:39











              • Sorry @PaichengWu it still doesn't work. I had to delay the line 2 code by fixed time 10 seconds and now it's not giving me any error. I understand this is not a fix and the code will throw an error again if the website loads for more than 10 seconds but for all my tests the page is being loaded within 5-8 seconds.

                – Prateek Vishwas
                Mar 25 at 14:10













              0












              0








              0







              revised on 2019-03-25



              I think the error is thrown because the doc is changed.



              Rewrite



              ' This is the Line2
              doc.getElementById("ContentPlaceHolder1_GridView1_chkboxSelectAll").Click
              'Wait 3 seconds till it selects all the checkboxes
              Application.Wait DateAdd("s", 3, Now)


              as



              ' This is the Line2 
              application.wait Application.Wait DateAdd("s", 1, Now)
              set doc = IE.document
              doc.getElementById("ContentPlaceHolder1_GridView1_chkboxSelectAll").Click
              'Wait 3 seconds till it selects all the checkboxes
              Application.Wait DateAdd("s", 3, Now)


              maybe helpful.






              share|improve this answer















              revised on 2019-03-25



              I think the error is thrown because the doc is changed.



              Rewrite



              ' This is the Line2
              doc.getElementById("ContentPlaceHolder1_GridView1_chkboxSelectAll").Click
              'Wait 3 seconds till it selects all the checkboxes
              Application.Wait DateAdd("s", 3, Now)


              as



              ' This is the Line2 
              application.wait Application.Wait DateAdd("s", 1, Now)
              set doc = IE.document
              doc.getElementById("ContentPlaceHolder1_GridView1_chkboxSelectAll").Click
              'Wait 3 seconds till it selects all the checkboxes
              Application.Wait DateAdd("s", 3, Now)


              maybe helpful.







              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Mar 25 at 0:37

























              answered Mar 24 at 10:42









              PaichengWuPaichengWu

              1,5641618




              1,5641618












              • I don't see doc been changed! However, I tried your suggestion and It's still throwing error 'Run-Time error '424' Object Required. It's not with all the rows. It works for for couple of line smoothly and then randomly the error appears. As I said the cause might be due to executing the code before the page is loaded completely. Is it possible to run doc.getElementById("ContentPlaceHolder1_GridView1_chkboxSelectAll").Click after few seconds (2 or 3) again when this error appears?

                – Prateek Vishwas
                Mar 24 at 16:05












              • When the error routes me to debug screen and I run the same highlighted line, It proceeds further without any error.

                – Prateek Vishwas
                Mar 24 at 16:11












              • I revised my answer. application.wait dateadd("s",1,now) is added to wait for one second.

                – PaichengWu
                Mar 25 at 0:39











              • Sorry @PaichengWu it still doesn't work. I had to delay the line 2 code by fixed time 10 seconds and now it's not giving me any error. I understand this is not a fix and the code will throw an error again if the website loads for more than 10 seconds but for all my tests the page is being loaded within 5-8 seconds.

                – Prateek Vishwas
                Mar 25 at 14:10

















              • I don't see doc been changed! However, I tried your suggestion and It's still throwing error 'Run-Time error '424' Object Required. It's not with all the rows. It works for for couple of line smoothly and then randomly the error appears. As I said the cause might be due to executing the code before the page is loaded completely. Is it possible to run doc.getElementById("ContentPlaceHolder1_GridView1_chkboxSelectAll").Click after few seconds (2 or 3) again when this error appears?

                – Prateek Vishwas
                Mar 24 at 16:05












              • When the error routes me to debug screen and I run the same highlighted line, It proceeds further without any error.

                – Prateek Vishwas
                Mar 24 at 16:11












              • I revised my answer. application.wait dateadd("s",1,now) is added to wait for one second.

                – PaichengWu
                Mar 25 at 0:39











              • Sorry @PaichengWu it still doesn't work. I had to delay the line 2 code by fixed time 10 seconds and now it's not giving me any error. I understand this is not a fix and the code will throw an error again if the website loads for more than 10 seconds but for all my tests the page is being loaded within 5-8 seconds.

                – Prateek Vishwas
                Mar 25 at 14:10
















              I don't see doc been changed! However, I tried your suggestion and It's still throwing error 'Run-Time error '424' Object Required. It's not with all the rows. It works for for couple of line smoothly and then randomly the error appears. As I said the cause might be due to executing the code before the page is loaded completely. Is it possible to run doc.getElementById("ContentPlaceHolder1_GridView1_chkboxSelectAll").Click after few seconds (2 or 3) again when this error appears?

              – Prateek Vishwas
              Mar 24 at 16:05






              I don't see doc been changed! However, I tried your suggestion and It's still throwing error 'Run-Time error '424' Object Required. It's not with all the rows. It works for for couple of line smoothly and then randomly the error appears. As I said the cause might be due to executing the code before the page is loaded completely. Is it possible to run doc.getElementById("ContentPlaceHolder1_GridView1_chkboxSelectAll").Click after few seconds (2 or 3) again when this error appears?

              – Prateek Vishwas
              Mar 24 at 16:05














              When the error routes me to debug screen and I run the same highlighted line, It proceeds further without any error.

              – Prateek Vishwas
              Mar 24 at 16:11






              When the error routes me to debug screen and I run the same highlighted line, It proceeds further without any error.

              – Prateek Vishwas
              Mar 24 at 16:11














              I revised my answer. application.wait dateadd("s",1,now) is added to wait for one second.

              – PaichengWu
              Mar 25 at 0:39





              I revised my answer. application.wait dateadd("s",1,now) is added to wait for one second.

              – PaichengWu
              Mar 25 at 0:39













              Sorry @PaichengWu it still doesn't work. I had to delay the line 2 code by fixed time 10 seconds and now it's not giving me any error. I understand this is not a fix and the code will throw an error again if the website loads for more than 10 seconds but for all my tests the page is being loaded within 5-8 seconds.

              – Prateek Vishwas
              Mar 25 at 14:10





              Sorry @PaichengWu it still doesn't work. I had to delay the line 2 code by fixed time 10 seconds and now it's not giving me any error. I understand this is not a fix and the code will throw an error again if the website loads for more than 10 seconds but for all my tests the page is being loaded within 5-8 seconds.

              – Prateek Vishwas
              Mar 25 at 14:10













              0














              Use proper page load waits after each .Navigate and .Click.



              While ie.Busy Or ie.readyState < 4: DoEvents: Wend


              Also, you can wrap elements that are throwing errors, related to timings, in timed loops which attempt to set the object reference



              Dim t As Date, ele As Object
              Const MAX_WAIT_SEC As Long = 10

              t = Timer
              Do
              On Error Resume Next
              Set ele = doc.getElementById("ContentPlaceHolder1_GridView1_chkboxSelectAll")
              On Error GoTo 0
              If Timer - t > MAX_WAIT_SEC Then Exit Do
              Loop While ele Is Nothing

              If Not ele Is Nothing Then
              ele.Click
              End If





              share|improve this answer



























                0














                Use proper page load waits after each .Navigate and .Click.



                While ie.Busy Or ie.readyState < 4: DoEvents: Wend


                Also, you can wrap elements that are throwing errors, related to timings, in timed loops which attempt to set the object reference



                Dim t As Date, ele As Object
                Const MAX_WAIT_SEC As Long = 10

                t = Timer
                Do
                On Error Resume Next
                Set ele = doc.getElementById("ContentPlaceHolder1_GridView1_chkboxSelectAll")
                On Error GoTo 0
                If Timer - t > MAX_WAIT_SEC Then Exit Do
                Loop While ele Is Nothing

                If Not ele Is Nothing Then
                ele.Click
                End If





                share|improve this answer

























                  0












                  0








                  0







                  Use proper page load waits after each .Navigate and .Click.



                  While ie.Busy Or ie.readyState < 4: DoEvents: Wend


                  Also, you can wrap elements that are throwing errors, related to timings, in timed loops which attempt to set the object reference



                  Dim t As Date, ele As Object
                  Const MAX_WAIT_SEC As Long = 10

                  t = Timer
                  Do
                  On Error Resume Next
                  Set ele = doc.getElementById("ContentPlaceHolder1_GridView1_chkboxSelectAll")
                  On Error GoTo 0
                  If Timer - t > MAX_WAIT_SEC Then Exit Do
                  Loop While ele Is Nothing

                  If Not ele Is Nothing Then
                  ele.Click
                  End If





                  share|improve this answer













                  Use proper page load waits after each .Navigate and .Click.



                  While ie.Busy Or ie.readyState < 4: DoEvents: Wend


                  Also, you can wrap elements that are throwing errors, related to timings, in timed loops which attempt to set the object reference



                  Dim t As Date, ele As Object
                  Const MAX_WAIT_SEC As Long = 10

                  t = Timer
                  Do
                  On Error Resume Next
                  Set ele = doc.getElementById("ContentPlaceHolder1_GridView1_chkboxSelectAll")
                  On Error GoTo 0
                  If Timer - t > MAX_WAIT_SEC Then Exit Do
                  Loop While ele Is Nothing

                  If Not ele Is Nothing Then
                  ele.Click
                  End If






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 25 at 8:55









                  QHarrQHarr

                  43.4k82448




                  43.4k82448





















                      0














                      I have removed below wait loop after line 1.



                       'Wait till it loads
                      Do While IE.Busy
                      Application.Wait DateAdd("s", 5, Now)
                      Loop


                      and added fix 10 seconds wait time Application.Wait DateAdd("s", 10, Now) just before



                       doc.getElementById("ContentPlaceHolder1_GridView1_chkboxSelectAll").Click
                      'Wait 3 seconds till it selects all the checkboxes
                      Application.Wait DateAdd("s", 3, Now)


                      So the final piece of code is as below and it's working!



                      'This is the Line1
                      doc.getElementById("ContentPlaceHolder1_search").Click

                      'Checkbox select all
                      'This is the Line2
                      Application.Wait DateAdd("s", 10, Now)
                      doc.getElementById("ContentPlaceHolder1_GridView1_chkboxSelectAll").Click
                      'Wait 3 seconds till it selects all the checkboxes
                      Application.Wait DateAdd("s", 3, Now)





                      share|improve this answer



























                        0














                        I have removed below wait loop after line 1.



                         'Wait till it loads
                        Do While IE.Busy
                        Application.Wait DateAdd("s", 5, Now)
                        Loop


                        and added fix 10 seconds wait time Application.Wait DateAdd("s", 10, Now) just before



                         doc.getElementById("ContentPlaceHolder1_GridView1_chkboxSelectAll").Click
                        'Wait 3 seconds till it selects all the checkboxes
                        Application.Wait DateAdd("s", 3, Now)


                        So the final piece of code is as below and it's working!



                        'This is the Line1
                        doc.getElementById("ContentPlaceHolder1_search").Click

                        'Checkbox select all
                        'This is the Line2
                        Application.Wait DateAdd("s", 10, Now)
                        doc.getElementById("ContentPlaceHolder1_GridView1_chkboxSelectAll").Click
                        'Wait 3 seconds till it selects all the checkboxes
                        Application.Wait DateAdd("s", 3, Now)





                        share|improve this answer

























                          0












                          0








                          0







                          I have removed below wait loop after line 1.



                           'Wait till it loads
                          Do While IE.Busy
                          Application.Wait DateAdd("s", 5, Now)
                          Loop


                          and added fix 10 seconds wait time Application.Wait DateAdd("s", 10, Now) just before



                           doc.getElementById("ContentPlaceHolder1_GridView1_chkboxSelectAll").Click
                          'Wait 3 seconds till it selects all the checkboxes
                          Application.Wait DateAdd("s", 3, Now)


                          So the final piece of code is as below and it's working!



                          'This is the Line1
                          doc.getElementById("ContentPlaceHolder1_search").Click

                          'Checkbox select all
                          'This is the Line2
                          Application.Wait DateAdd("s", 10, Now)
                          doc.getElementById("ContentPlaceHolder1_GridView1_chkboxSelectAll").Click
                          'Wait 3 seconds till it selects all the checkboxes
                          Application.Wait DateAdd("s", 3, Now)





                          share|improve this answer













                          I have removed below wait loop after line 1.



                           'Wait till it loads
                          Do While IE.Busy
                          Application.Wait DateAdd("s", 5, Now)
                          Loop


                          and added fix 10 seconds wait time Application.Wait DateAdd("s", 10, Now) just before



                           doc.getElementById("ContentPlaceHolder1_GridView1_chkboxSelectAll").Click
                          'Wait 3 seconds till it selects all the checkboxes
                          Application.Wait DateAdd("s", 3, Now)


                          So the final piece of code is as below and it's working!



                          'This is the Line1
                          doc.getElementById("ContentPlaceHolder1_search").Click

                          'Checkbox select all
                          'This is the Line2
                          Application.Wait DateAdd("s", 10, Now)
                          doc.getElementById("ContentPlaceHolder1_GridView1_chkboxSelectAll").Click
                          'Wait 3 seconds till it selects all the checkboxes
                          Application.Wait DateAdd("s", 3, Now)






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Mar 25 at 14:19









                          Prateek VishwasPrateek Vishwas

                          7118




                          7118



























                              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%2f55321474%2ferror-automating-website-data-entry-as-the-website-is-still-loading%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

                              Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                              Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                              Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript