• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Help! Internet Explorer Dropdown ComboBox Navigation using VBA Macro

Spaul

New Member
I am having difficulty trying to automate a dropdown comboBox in internet explorer using an Excel Macro. Note that I am very new to VBA language and web scraping.

The code I am using unsuccessfully is:

'Change Posting Period

Dim posting As Object
Set posting = ie.Document.getElementById("inpt_postingperiod2")
posting.Value = ActiveWorkbook.Sheets("RMA").Range("C5").Value

'The value in this cell C5 in this instance is: Aug 2019

In internet explorer this code will change the the text that is displayed in the dropdown box but when I later submit the page, the underlying value was never really changed.

The script related to the dropdown is:

<input name="inpt_postingperiod" title="Sep 2019" class="dropdownInput textbox uir-field-active" id="inpt_postingperiod2" role="combobox" aria-labelledby="postingperiod_fs_lbl" style="width: 280px; background-color: rgb(255, 255, 255);" contenteditable="false" onkeydown="getDropdown(this).handleKeydown(event);" onkeypress="getDropdown(this).handleKeypress(event);" onfocus="getDropdown(this).handleOnFocus(event);" onblur="getDropdown(this).handleOnBlur(event);" type="text" value="Sep 2019" autocomplete="off">

And the script for the dropdown option items:

<div class="ns-dropdown" style="display: none;" data-name="postingperiod" data-settings='{"flags":-2147483520,"width":280,"minWidth":280,"mandatory":true}' data-default-option="4" data-options='[{"value":"127","text":"May 2019"},{"value":"128","text":"Jun 2019"},{"value":"129","text":"Jul 2019"},{"value":"131","text":"Aug 2019"},{"value":"132","text":"Sep 2019"},{"value":"133","text":"Oct 2019"},{"value":"138","text":"Nov 2019"},{"value":"139","text":"Dec 2019"},{"value":"140","text":"Jan 2020"},{"value":"142","text":"Feb 2020"},{"value":"143","text":"Mar 2020"},{"value":"144","text":"Apr 2020"}]' data-initialized="T">
</div>

Note that the Excel value of Aug 2019 should be selected from the dropdown options list. Thus, in order to automate this, I cannot use the value/index number since this will change in the future; I need to match the excel cell value of MMM YYYY to the MMM YYYY in the dropdown list (in this example Aug 2019).

Thank you for all the help!
 
Back
Top