PDA

View Full Version : VBA Finding String on Webpage



bbmaly
08-14-2013, 10:54 PM
Hi All of you,

I have just registered on this forum and this is my first post here but I think I need your help.

As I am some kind of beginner in VBA coding and I am not able to solve all of my issue in VBA I would like to ask you if you could not help me with the following issue.


Sub GetIE()

Dim IE As Object

Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True

IE.Navigate "" '(here should be link to the VIES webpage but unfortunately I am not able to submit post with links yet - you can type in google VIES and find this lind on your own )
Do While IE.readyState <> 4: Loop

With IE.Document
.getelementByID("countryCombobox").Value = "FI"
.getelementByID("requestedMsCode").Value = "FI"
.getelementByID("number").Value = "04579451"
.getelementByID("submit").Click
End With

Do While IE.readyState <> 4: Loop

Set doc = IE.Document.body

tb = IE.Document.getelementByID("vatResponseFormTable")
Set s = tb.innertext

szuk = InStr(s, "Yes, valid VAT number")

Range("a1").Value = szuk

End Sub


This is the code, which I wrote not so far ago and it works. Unfortunately, not entirely. While running code, no error will appear, but code is not able to find this "Yes, valid VAT number" on the webpage and I do not know why. Almost the same code of my friend in VB Script is workin properly, but this is mine in VBA and I want to run this code.

Could you help me with this case or advise something?

Thank you in advance.