Website not updating after inserting drop down option via VBA

Kmanbozzy

New Member
Joined
Apr 18, 2016
Messages
18
9
I've tired a lot of different approaches and still have not figured out any way to overcome the issue. When use the .selectedindex = 10, the option appears just like i wont it to, but the date range boxes will not appear after i've picked the option. ive tired .focus .fireevents .click and many other attempts. nothing i seem to do works. What i want to know is when i click on a drop down menu on a webiste, what is governing the following action of appearing the date ranges? is it a javascirpt function? If so where in the IE inspect element would i find where that function is being called after selecting an option from the drop down list? Then how would i call that function in VBA to appear those date ranges?

Here is my VBA code:
Code:
IE.document.getelementbyid("statementFilterDropDown").Focus
    IE.document.getelementbyid("statementFilterDropDown").selectedindex = 10
    IE.document.getelementbyid("statementFilterDropDown").fireEvent "onchange"
    IE.document.getelementbyid("statementFilterDropDown").Click
    IE.document.getelementbyid("dateRangeFrom").Value = StartDate
    IE.document.getelementbyid("dateRangeTo").Value = EndDate

The thing is, it all works once the date ranges are visible, which only happens after the option "date range" is chosen from the drop down menu manually. the .selectedindex = 10 works correctly, but just wont update the website to view the date ranges.

here is the html script
qOphjIz.png
 
Last edited:

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Hi Kmanbozzy,
what is the URL you're trying to test your code on? Just the info you've provided is not enough for me to spot what goes wrong, for that I'd need to tinker a bit myself.
Cheers,
Koen
 
Upvote 0
well its my bank account, so you wont be able to get to the screen unless you have the same bank, its citi bank is there anything i can get for you to make it easier?
 
Upvote 0
Hi Kmanbozzy,
mmm, tough one. Don't have a Citibank account, so have no clue what code they are using, sorry, hope that someone else can help you on.
G'luck,
Koen
 
Upvote 0
Using your browser's developer tools (press the F12 key), see if the select element has any event(s). Your code suggests that it has a 'change' event, in which case call dispatchEvent on it like this (reference to MS HTML Object Library is required):

Code:
    Dim HTMLdoc As HTMLDocument
    Dim selectElement As HTMLSelectElement
    Dim changeEvent As Object
    
    'After IE page has fully loaded
    Set HTMLdoc = IE.document
    Set changeEvent = HTMLdoc.createEvent("HTMLEvents")
    changeEvent.initEvent "change", True, False
    
    Set selectElement = HTMLdoc.getElementById("statementFilterDropDown")
    selectElement.Focus
    selectElement.selectedIndex = 10
    selectElement.dispatchEvent changeEvent
    DoEvents
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top