1

I have a problem when trying to scrape data from website. It is Run-time error '424': Object required My code:

Option Explicit
Sub GetData()

Dim IE As New SHDocVw.InternetExplorer

IE.Visible = True

IE.Navigate "abc.com"

Do While IE.ReadyState <> READYSTATE_COMPLETE
Loop

IE.Document.forms("vinSearchForm").elements("vin").Value = 
"******"
IE.Document.forms("vinSearchForm").elements("vinSearch").Click
Sheets("Sheet1").Select
Range("A10").Select 
IE.Document.forms("vinSummaryForm").elements
("test_vinSummary_carSpecification_$4").Value = Range("A10").Value

End Sub

What I want is that to show result "2004*********" in Range("A10"). Pls kindly help me accordingly. Thanks.

v1787v
  • 45
  • 1
  • 5

1 Answers1

0

Although not the best way but should work for you

Option Explicit
Sub Autocheck()

    Dim IE As New SHDocVw.InternetExplorer

    IE.Visible = True

    IE.Navigate "Autocheck.com"

    Do While IE.ReadyState <> READYSTATE_COMPLETE Or IE.Busy
        DoEvents
    Loop

    Application.Wait Now + TimeSerial(0, 0, 5)
    IE.Document.forms("vinSearchForm").elements("vin").Value = "JTDKB22U140021007"
    IE.Document.forms("vinSearchForm").elements("vinSearch").Click

    Do While IE.ReadyState <> READYSTATE_COMPLETE Or IE.Busy
        DoEvents
    Loop

    Application.Wait Now + TimeSerial(0, 0, 5)
    Range("A10").Value = Split(IE.Document.getelementbyid("test_vinSummary_carSpecification_$4").innerText, vbNewLine)(1)

    IE.Quit
    Set IE = Nothing

End Sub
Santosh
  • 12,175
  • 4
  • 41
  • 72
  • Sir.. I works perfectly when I run it 2 or 3 times at first time, but now it is still error with "IE.Document.forms("vinSearchForm").elements("vin").Value = "JTDKB22U140021007" : Error : Run-time error '424': Object required . May you assist to fix it sir? – v1787v Jan 17 '19 at 02:39
  • Sir, I know it. Because of IE is still running so it is error. May you advise which code for closing IE from background? – v1787v Jan 17 '19 at 02:56
  • @v1787v IE.Quit Set IE = Nothing – Santosh Jan 17 '19 at 02:58
  • Sir, I want to get this result too "Style / Body: Hatchback 4D Engine: 1.5L I4 EFI" So I add code "Range("A11").Value = Split(IE.Document.getElementById("test_vinSummary_carSpecification_$4").innerText, vbNewLine)(6)" But the result has only "Style / Body: Hatchback 4D" May you help me one more step, sir? So Sorry Sir for repeating !!! – v1787v Jan 17 '19 at 04:02
  • @v1787v ofcourse Sir, `Split(IE.Document.getelementbyid("test_vinSummary_carSpecification_$4").innerText, vbNewLine)(6)` here you go sir, no problem sir!!! – Santosh Jan 17 '19 at 04:08
  • Sir... So sorry to disturb you again.. May you guide me how to pull data from this web : https://vehicleverification.esma.gov.ae/. HTML in this website is not the same as above web. VIn Test : SCA664S53FUX53460. Appreciated your help sir !! – v1787v Feb 21 '19 at 05:14
  • Sir, I can not find “Form” and “ID” in Inspection element on this new website so I can not make it work – v1787v Feb 21 '19 at 05:58