Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using VBA to extract information from Internet explorer - I'm stuck

Status
Not open for further replies.

Neil_54321

Programmer
Jan 8, 2021
1
GB
I designed some code a while ago using VBA and Excel, to check which people on my database are still VAT registered. I'm based in the UK, and I was using a European website, but because of Brexit it's no longer working! I changed it to a British website now, and I managed to get the code to enter the VAT number from Excel into the webpage, but I can't find the Id or name of the submit button, so I'm not able to submit it. After I've submitted it I'll probably need some more help with the next page, but I'll see if anyone can help me solve this one first. Many thanks for your help. Here's the code (I put ??? in place of the ID and name for now).


Sub CheckVatPlayers()

Dim x As Integer, y As Integer, z As String
Dim objIE As InternetExplorer
Dim aEle As HTMLLinkElement
Dim findtext As String, player As String

x = 2



Set objIE = New InternetExplorer
objIE.Visible = True


Do Until Cells(x, 1) = ""

'If Left(Cells(x, 4), 2) <> "GB" Then
'Cells(x, 4) = "GB" & Replace(Cells(x, 4), " ", "")
'End If

objIE.Navigate "

Do While objIE.Busy = True Or objIE.ReadyState <> 4: DoEvents: Loop
Application.Wait Now + #12:00:01 AM#


objIE.Document.getElementById("target").Value = Cells(x, 4).Value


objIE.Document.getElementsByName("???")(0).Click
'objIE.Document.getElementById("???").Click

Do While objIE.Busy = True Or objIE.ReadyState <> 4: DoEvents: Loop
Application.Wait Now + #12:00:01 AM#


y = 2


For Each aEle In objIE.Document.getElementsByClassName("VAT registration details")

Debug.Print aEle.innerText

z = Trim(aEle.innerText)
Cells(x, 7) = z

If Left(z, 1) = "V" Then
Cells(x, 7).Font.Color = vbBlack
Else: Cells(x, 7).Font.Color = vbRed
End If

With Cells(x, 6)
.Value = Date
.NumberFormat = "dd/mm/yyyy"
End With

y = y + 1

Next

x = x + 1
Loop

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top