VBA Web Form Scraping - Blank field

no_Fate

New Member
Joined
Jan 22, 2015
Messages
6
Hi everyone,

I'm using VBA to populate a web form and 99% of it is working just fine.
I have one problem, though, when trying to populate a field that depends on a previous one. This is an internal (corporate) web form so I can't use a real example, but here is an exercise:

Imagine I want to populate two fields: one being the "Month" and the other being the "day". No matter the data I enter in the Month and although returning no error, the day field is always left blank.
I'm afraid this is somehow related to some kind of validation (as you know, a standard use of the form would't allow me to select February and then have have the day 31st available...). I even tried thing like sending a tabkey between both, just in case, but it still wont work.

Here's the code I'm using (fictional web site address):
Code:
<code>Sub webform()

Dim IE As Object
Set IE = New InternetExplorerMedium
IE.Visible = True

IE.Navigate "http://www.fakewebsite.com"

Do While IE.Busy
Application.Wait DateAdd("s", 1, Now)
Loop

IE.document.getElementById("month").Value = "April"
IE.document.getElementById("day").Value = "21"


End Sub</code>

Here's what I think is the needed HTML and Javascript (I'm very limited regarding those) and sorry for the pictures but the forum is blocking e from publishing this code...

HTML:

dzMSdl2.png


Java:

SPe12X3.png


Thank you.
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Hi

Does this work?

Code:
Sub WForm()
Dim ie As Object, ftb, i%, stb
i = 1
On Error GoTo 0
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = 1
ie.navigate "https://www.mrexcel.com/forum/search.php"       ' desired page here
While ie.busy
    DoEvents
Wend
Set ftb = ie.Document.getElementById("keyword")             ' first field
ftb.Value = "pivot"
While ftb.Value <> "pivot"
    i = i + 1: DoEvents
Wend
Set stb = ie.Document.getElementById("userfield_txt")       ' second field
stb.Value = "billy"
While stb.Value <> "billy"
    i = i + 1: DoEvents
Wend
End Sub
 
Upvote 0
Hi Worf,

Thank you for trying.
Unfortunately it is not working as the outcome is the same: first combo box is populated but not the second one (which when manually opened has no values to be selected now, as if it is still missing the first combo to be validated).
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

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