I am working on a web automation project. I have come up to a web drop box to where I have to choose a value. I have a query selector which works fine in doing the job but now I want that query selector to find those values in the drop box which are taken from a cell value of excel sheet.
With .document.querySelector("[value='536']")
.Selected = True
.dispatchEvent evt
End With
Above is the query which works fine. But now I want to replace "536" from cell "A1" . I have tried to replace ("[value='536']") with ([value='thisWorkbool.sheets.("sheet1").Range(A1).value']") but it shows error.
Option Explicit
Public Sub FillForm()
Dim ie As Object, tool As Workbook
Set tool = ActiveWorkbook
Set ie = CreateObject("InternetExplorer.application")
With ie
.Visible = True
.navigate "https://******.com/"
While .Busy Or .readyState < 4: DoEvents: Wend
With .document
.getElementById("txtUserName").Value = "09100107801-01"
.getElementById("txtPassword").Value = "Abc@1234"
.getElementById("btnSubmit").Click
End With
While .Busy Or .readyState < 4: DoEvents: Wend
.navigate "https://***************"
While .Busy Or .readyState < 4: DoEvents: Wend
Dim evt As Object
Set evt = .document.createEvent("HTMLEvents")
evt.initEvent "change", True, False
With .document.querySelector("[value='536']")
.Selected = True
.dispatchEvent evt
End With
end sub
How to put the value from the cell value "A1" of exel sheet in above code.