I’m using Access VBA to open Internet Explorer and fill out a form on a website.
This form has id of auto number which changes every so often but “_id” as per below is always the same, and I’m not sure if or how I can use the “_id” to insert the value into that field
this is what i have so far, thanks Tim
im not sure how exactly this site works as im fairly new here but this is what i have so far, one last question on Radio Buttons
Dim ie As InternetExplorer
Dim url As String
Dim htmlDoc As MSHTML.HTMLDocument ' html object lib
Dim htmlInputElemen As MSHTML.HTMLInputElement
Dim htmlElementCol As MSHTML.IHTMLElementCollection
url = www.abc.com
ie.navigate url
‘ this is for text box
Set htmlDoc = ie.Document
Set htmlElementCol = htmlDoc.getElementsByTagName("INPUT")
For Each htmlInputElemen In htmlElementCol
If htmlInputElemen.getAttribute("title") = "myTitle" Then
htmlInputElemen.Value = “myTitle”
' ElseIf htmlInputElemen.getAttribute("title") = "myTitle2" Then
htmlInputElemen.Value = “myTitle2”
End If
Next htmlInputElemen
‘ this is for combo box
Set htmlElementCol = htmlDoc.getElementsByTagName("select")
Dim htmlSelectElem As MSHTML.HTMLSelectElement
For Each htmlSelectElem In htmlElementCol
If htmlSelectElem.getAttribute("title") = "myComboBox" Then
htmlSelectElem.Value = “myComboBoxValue”
End If
Next htmlSelectElem
‘now I have radio buttons which im not sure how to click using title, any ideas?
I tried this but no luck
Set htmlElementCol = htmlDoc.getElementsByTagName("span")
Dim htmlSpanElem As MSHTML.HTMLSpanElement
For Each htmlSpanElem In htmlElementCol
If htmlSpanElem.getAttribute("title") = “ABC” Then
htmlSpanElem.Click
End If
Next htmlSpanElem
<span class="ms-RadioText" title="ABC">
<input id="234sd87s89df">
<label for="234sd87s89df ">ABC</label>
EDIT: here’s the same code refactored as a function
Usage: