Caleeco
Well-known Member
- Joined
- Jan 9, 2016
- Messages
- 980
- Office Version
- 2010
- Platform
- Windows
Hello,
I'm trying to develop a spreadsheet that will load webpage and interact with it. I have been able to load the website, login and click some buttons.
However I can't seem to click the "Enter Time" from the "Action" dropdown using the same method.
I have attached the InspectElement code & the VBA snippet below.
Can anyone advise how to do this?
Many Thanks
Caleeco
I'm trying to develop a spreadsheet that will load webpage and interact with it. I have been able to load the website, login and click some buttons.
However I can't seem to click the "Enter Time" from the "Action" dropdown using the same method.
I have attached the InspectElement code & the VBA snippet below.
Can anyone advise how to do this?
Many Thanks
Caleeco
VBA Code:
Sub Uploader()
'-- Create instance for IE Object & Navigate to Website
IE.Visible = True
IE.navigate "https://somewebsite.com"
Do While IE.Busy = True Or IE.readyState <> 4: DoEvents: Loop 'Wait until page has loaded
Set HTMLDoc = IE.document
'-- Loop button tags and click Actions Dropdown
Call Click_HTML_Element("button", "Actions", "2") 'This Works
Call Click_HTML_Element("div", "Enter Time", "1") 'This doesnt work
' Application.SendKeys "{DOWN}"
' Application.SendKeys "{Enter}"
End Sub
Function Click_HTML_Element(Element As String, Tag As String, WaitTime As String)
Set HTMLButtons = HTMLDoc.getElementsByTagName(Element)
Application.Wait (Now + TimeValue("00:00:0" & WaitTime))
Do While IE.Busy = True Or IE.readyState <> 4: DoEvents: Loop
For Each ButtonTag In HTMLButtons
If Left(ButtonTag.innerText, Len(Tag)) = Tag Then
ButtonTag.Click
Exit For
End If
Next ButtonTag
End Function