+ Reply to Thread
Results 1 to 8 of 8

VBA HTML Object Internet Explorer automation

  1. #1
    Registered User
    Join Date
    03-31-2020
    Location
    Denmark
    MS-Off Ver
    365
    Posts
    5

    VBA HTML Object Internet Explorer automation

    How do I select an option from a dropdown menu and update the webpage. Code:

    Please Login or Register  to view this content.
    then I navigate to a URL and I fetch the dropdown menu using html id and put value=my desired value

    Please Login or Register  to view this content.
    I successfully get the option. But, the website doesn't update? e.g. filling up other fields.

    I believe some javascript needs to be run. How can i fix this using VBA?

    Source code for dropdown menu field:

  2. #2
    Forum Guru Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    Excel 2010 on Linux
    Posts
    11,961

    Re: VBA HTML Object Internet Explorer automation

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however it has been brought to our attention that the same query has been posted on one or more other forums and you have not provided the required cross-post link(s) here.

    Please see Forum Rule #3 about cross-posting and adjust accordingly. Read this to understand why we (and other sites like us) consider this to be important.

    As you are new I am adding it for you.Please read forum rules. Thanks

    https://www.mrexcel.com/board/thread...ation.1129212/

  3. #3
    Registered User
    Join Date
    03-31-2020
    Location
    Denmark
    MS-Off Ver
    365
    Posts
    5

    Re: VBA HTML Object Internet Explorer automation

    Thank you! Great, I will keep this in mind going forward

  4. #4
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 2016
    Posts
    4,907

    Re: VBA HTML Object Internet Explorer automation

    After setting the dropdown option, you could try:

    Please Login or Register  to view this content.
    Can't guarantee it will work, depends on the site, and yes potentially you need to actually invoke a js function. Without the URL I can't suggest more, but try the above line, and hopefully it is that simple.
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  5. #5
    Registered User
    Join Date
    03-31-2020
    Location
    Denmark
    MS-Off Ver
    365
    Posts
    5

    Re: VBA HTML Object Internet Explorer automation

    I tried the fireevent("onchange") but it didn't work.

    To access the page here, a login is required that's why I can't share it. What to do?

  6. #6
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 2016
    Posts
    4,907

    Re: VBA HTML Object Internet Explorer automation

    I haven't experienced it myself, and can't say I see how it would make a difference, but I have read posts in the past where people first gave focus to the element to make it work. So it is a long shot, but you could try:

    Please Login or Register  to view this content.
    Without seeing the code behind the page I really can't guess more. (I do understand you can't share it)

    Edit: for me it always works with brackets, but you could try removing the brackets around "onchange"
    Last edited by Arkadi; 03-31-2020 at 02:16 PM.

  7. #7
    Registered User
    Join Date
    03-31-2020
    Location
    Denmark
    MS-Off Ver
    365
    Posts
    5

    Re: VBA HTML Object Internet Explorer automation

    Sourcode for dropdown:
    <div class="rcbSlide" style="z-index: 6000; display: block; width: 206px; top: 235px; left: 412px; overflow:
    visible;">
    <div id="ctl00_MainContent_CreateWebForm__SubjectComboBox_ComboBox_DropDown"
    class="RadComboBoxDropDown RadComboBoxDropDown_Telerik " style="width: 204px; display: block;
    top: 0px; visibility: visible; transition: none 0s ease 0s;">

    <div class="rcbScroll rcbWidth" style="height: 126px;">
    <ul class="rcbList">
    <li class="rcbHovered">Forespørgsel til Energinet</li>
    <li class="rcbItem">Måledata</li>
    <li class="rcbItem">Målepunkt eller ad hoc spørgsmål</li>
    <li class="rcbItem">Orientering til alle</li>
    <li class="rcbItem">Priser</li>
    <li class="rcbItem">Pristilknytninger</li>
    </ul>
    </div>
    </div>
    </div>

    I am doing this:
    HTMLDoc.getElementById("ctl00_MainContent_CreateWebForm__SubjectComboBox_ComboBox_Arrow").Click
    HTMLDoc.getElementById("ctl00_MainContent_CreateWebForm__SubjectComboBox_ComboBox_DropDown").Focus
    'HTMLDoc.getElementById("ctl00_MainContent_CreateWebForm__SubjectComboBox_ComboBox_DropDown").Value = "Målepunkt eller ad hoc spørgsmål"
    HTMLDoc.getElementById("ctl00_MainContent_CreateWebForm__SubjectComboBox_ComboBox_DropDown").FireEvent ("onchange")

    The value part doesn't work as this is not an attribute. I think I need to go down the rcb list and select/click on item 3? How?

  8. #8
    Registered User
    Join Date
    03-31-2020
    Location
    Denmark
    MS-Off Ver
    365
    Posts
    5

    Re: VBA HTML Object Internet Explorer automation

    ctl00_MainContent_CreateWebForm__SubjectComboBox_ComboBox_Arrow is the arrow button to open the dropdown list.

    I need to go down the dropdown list and select item 3 or click on item 3 - How may I do this?

    Thanks in advance.

    Added at the request of the OP by PLM :
    This is the xpath alternative
    Command = Click
    xpath=//*[@id="ctl00_MainContent_CreateWebForm__SubjectComboBox_ComboBox_DropDown"]/div/ul/li[3]

    This works but I need a VBA alternative to this - how can this be done in VBA?
    Last edited by Pepe Le Mokko; 04-01-2020 at 06:26 AM. Reason: Added text to post

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Internet Explorer - Automation Problem
    By mitko007 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-10-2015, 05:03 AM
  2. VBA Macro to Internet Explorer automation
    By darkstarpepper in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 04-09-2015, 12:22 PM
  3. Internet Explorer Automation
    By jagguvaka in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-22-2013, 04:35 AM
  4. Internet Explorer Macro Automation
    By kboy1289 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-15-2013, 03:48 PM
  5. VBA Internet Explorer Automation using frames
    By kboy1289 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-16-2012, 04:43 PM
  6. Internet explorer download automation
    By exc4libur in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-28-2012, 05:23 PM
  7. Very Few Posts regarding Internet Explorer Automation
    By Lisa4legin in forum Excel General
    Replies: 3
    Last Post: 05-09-2012, 02:44 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1