1

I'm trying to select a value from a dropdown on a IE page.

I have tried a lot of methods. It doesn't do anything.

Source code of the drop down:
source code of the drop down

Codes I have tried, to select the value with "EVR" (there is only one value in the drop down):

Application.Wait Now + #12:00:06 AM# IE.Visible = True 'IE.document.getElementById("fileOnlineReturnTaxType").Value = "EVR" 'IE.document.getElementsByName("taxType").Value = "84" 'Set oSelect = IE.document.getElementById("fileOnlineReturnTaxType") ' oSelect.Focus ' oSelect.selectedIndex = 1 ' oSelect.FireEvent "onchange" 'IE.document.getElementById("fileOnlineReturnTaxType").Click 'Set Link3 = IE.document.getElementsByTagName("span") ' For Each t In Link3 ' If t.innerText = "Select a tax type..." Then ' MsgBox (t.innerText) ' t.Click ' Exit For 'End If 'Next t 
2
  • What are the values of IE.document.getElementsByName("taxType").Value at debug? Is the value "Select Tax Type"? Look at Microsoft Internet Controls and HTML library, you can then set the object properly so, you can put the drop down in an object and debug a little better. Commented Feb 27, 2019 at 10:08
  • hi when I try : test = IE.document.getElementsByName("taxType")(0).Value then it will have then test = "" en with test = IE.document.getElementsByName("taxType")(1).Value it has this error: object variable or with block variable not set Commented Feb 27, 2019 at 10:39

1 Answer 1

1

Try adding a change event and firing that

Option Explicit Public Sub MakeSelection() Dim ie As New InternetExplorer With ie .Visible = True .Navigate2 "url" While .Busy Or .readyState < 4: DoEvents: Wend Dim event_onChange As Object Set event_onChange = .document.createEvent("HTMLEvents") event_onChange.initEvent "change", True, False With .document.querySelector("#fileOnlineReturnTaxType") .selectedIndex = 1 .FireEvent "onchange" .dispatchEvent event_onChange End With Stop .Quit End With End Sub 
Sign up to request clarification or add additional context in comments.

1 Comment

wow I dont see the selected value in the dropdown box but it works!!!! Thank you very muchhh! I searched for this part for hours!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.