Error in VBA Code - Web Scrapping - Take Data from Worksheet and Bring Data from Web to Excel

mayur7393

New Member
Joined
Mar 9, 2016
Messages
21
Hello Guys,

I have a list of CR Numbers in Column A (count 4000) and my purpose is to extract "VAT Number" and "Arabic Name" registered against the CR number on the VAT Website. For ease, I am putting a sample CR as "1010069143"

Following is the code developed by me and I am facing the following issues. I tried looking at numerous websites, tutorials and I am badly stuck with this. Can you please assist me in adding few comments / rectify the command to help active my objective.

Sub OpenWebpage()


Dim IE As New InternetExplorer
Dim HTMLDOC As HTMLDocument
Dim HTMLINPUT As IHTMLElement
Dim HTMLButtons As IHTMLElementCollection
Dim HTMLButton As IHTMLElement
Dim x As Integer


For x = 2 To 400


IE.Visible = True
IE.Navigate "https://www.vat.gov.sa/en/vat-taxpayer-lookup"


Do While IE.readyState <> READYSTATE_COMPLETE
Loop


IE.document.forms("company-lookup-form").elements("edit-search-parameter").Value = 2
IE.document.forms("company-lookup-form").elements("edit-vat-account-no").Value = Cells(x, 1)
IE.document.forms("company-lookup-form").elements("edit-submit").Click


' I have to do this because I am unable to write a code to click on Catpcha thus I don't mind to manually complete the captcha and VBA to then take the process forward.
Application.Wait Now + TimeValue("00:00:05")
IE.document.getelementsbyID("edit-cr--RUcsBn-vb_E").Value = Cells(x, 1)
IE.document.getelementsbyID("edit-submit--s2QHBIxZ_78").Click


IE.document.getelementsbyClass("odd").Value = Cells(x, 2)
IE.document.getelementsbyClass("Even").Value = Cells(x, 3)


Next x
End Sub
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

Forum statistics

Threads
1,214,944
Messages
6,122,387
Members
449,080
Latest member
Armadillos

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top