I am trying to write a vba code in order to follow this process:
Automatic Web form fill in and submitting (a new web page opens with the answer http://ec.e
Try this
Sub getData()
'~~~~Variable declaration~~~~'
Dim IE As Object
Dim country As Object
Dim num As Object
Dim btn As Object
Dim tlb As Object, td As Object
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = False
IE.navigate "http://ec.europa.eu/taxation_customs/vies/?locale=en"
'Wait till page is loaded
Do While IE.readystate <> 4
DoEvents
Loop
Set country = IE.document.getelementbyid("countryCombobox")
country.Value = "FR" 'set the value for Member state
'Pause the code for 5 sec
Application.Wait Now + TimeSerial(0, 0, 5)
'
Set num = IE.document.getelementbyid("number")
num.Value = "27435044714" 'set the Vat number
Application.Wait Now + TimeSerial(0, 0, 5)
Set btn = IE.document.getelementbyid("submit")
btn.Click ' click the verify button
'Wait till page is loaded
Do While IE.readystate <> 4: DoEvents: Loop
'Pause the code for 5 sec
Application.Wait Now + TimeSerial(0, 0, 10)
Set tbl = IE.document.getelementbyid("vatResponseFormTable")
For Each td In tbl.getelementsbytagname("td")
If td.innerText = "Name" Then
MsgBox "Name : " & td.NextSibling.innerText
ElseIf td.innerText = "Address" Then
MsgBox "Address : " & td.NextSibling.innerText
ElseIf td.innerText = "Consultation Number" Then
MsgBox "Consultation Number : " & td.NextSibling.innerText
End If
Next
IE.Quit
Set IE = Nothing
End Sub