Excel VBA & IE 11 - Unable to refresh page after selecting value in a dropdown

前端 未结 2 1586
星月不相逢
星月不相逢 2021-01-23 22:13

I\'m trying to get the currency exchange rate offered by WorldRemit for a pair of currencies. I want to change the value in the \'Send From\' dropdown list on the top left corne

2条回答
  •  生来不讨喜
    2021-01-23 22:40

    Apparently FireEvent doesn't work all that well with IE 11 so need to use CreatEvent + initEvent + dispatchEvent

    Working code snippet below:

    Dim fromSelect As HTMLSelectElement
    Dim evt As Object
    
    Set evt = HTMLdoc.createEvent("HTMLEvents")
    evt.initEvent "change", True, False
    Set fromSelect = HTMLdoc.getElementById("selectFrom")
    optionIndex = Find_Select_Option(fromSelect, "Germany")
    If optionIndex >= 0 Then
        fromSelect.selectedIndex = optionIndex
        fromSelect.dispatchEvent evt
    End If
    

提交回复
热议问题