destructo4000
New Member
- Joined
- Jan 22, 2020
- Messages
- 6
- Office Version
- 365
- Platform
- 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
_______________________________
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
_______________________________