HTML Through VBA - Trigger event on HTML Form

destructo4000

New Member
Joined
Jan 22, 2020
Messages
6
Office Version
  1. 365
Platform
  1. Windows
Hi,
Long time fan, first time poster. Also this is my first attempt at manipulating web stuff, so apologies if any phrasing is misleading.

I am entering data on a website (to autoamte a data scrape). There are 4 fields:
- Post Code (Text box)
- Occupancy (Drop down)
- Building Type (Drop down - options triggered from Occupancy selection)
- Year Built (Text box)

The issue is that when the code is run, the Building Type has not been selected and the drop down menu is not populated. I presume (dangerously) that some kind of event needs to be triggered when entering the occupancy. Help would be greatly appreciated.

Code below and image for the HTML attached.
_______________________________
Sub temp()

Dim ie As Object
Set ie = CreateObject("InternetExplorer.application")
ie.Visible = True
ie.navigate "[web address]"
While ie.busy
DoEvents
Wend
Application.Wait (Now + TimeValue("0:00:01"))

'IE Objects
Dim PostCode As Variant
Dim Occupancy As Variant
Dim BuildingType As Variant
Dim YearBuilt As Variant

Set PostCode = ie.document.getElementById("postcode")
Set Occupancy = ie.document.getElementById("Occupancy")
Set BuildingType = ie.document.getElementById("BuildingType")
Set YearBuilt = ie.document.getElementById("YearBuilt")

PostCode.Value = "[PostCode]"

Occupancy.selectedIndex = 7

BuildingType.selectedIndex = 1

YearBuilt.Value = "1850"

End Sub
_______________________________
 

Attachments

  • htmlQuery.PNG
    htmlQuery.PNG
    34.3 KB · Views: 45

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Yes most likely and XHTML/AJAX request is taking place to populate those lists based on the prior selections.
 
Upvote 0
Thanks for taking a look.
I'm unfamiliar with the terms, but is there something i can add to the vba code that might trigger the XHTML/AJAX request?
 
Upvote 0
Welcome :)
I was referring to how the data was called from the web server to a web page normally by a browser. You would need to determine what the javascript is sending/receiving from the web server to populate items. Then you could write VBA code to emulate that. Without more info I don't have much more of an answer.
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,771
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