+ Reply to Thread
Results 1 to 18 of 18

VBA with IE DropDowns

  1. #1
    Registered User
    Join Date
    10-28-2010
    Location
    Ottawa, Ontario
    MS-Off Ver
    Excel 2003
    Posts
    17

    VBA with IE DropDowns

    I am trying to have VBA change a dropdown box in an ie window. I have manipulated it in other ways, I just cant get this code to work.

    The HTML Form name is "form1"

    This is the HTML Code.

    Please Login or Register  to view this content.
    I have have tried:

    Please Login or Register  to view this content.
    Please Help.

    Thank you!

  2. #2
    Registered User
    Join Date
    10-28-2010
    Location
    Ottawa, Ontario
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: VBA with IE DropDowns

    Anybody know how to do this? I still can't get it working.
    Thanks.

  3. #3
    Registered User
    Join Date
    10-28-2010
    Location
    Ottawa, Ontario
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: VBA with IE DropDowns

    Ok using this code:

    obrowser.document.getElementById("slctMunc").Focus
    obrowser.document.getElementById("slctMunc").selectedIndex = 50

    The browser changes momentarily and then blinks back to the original selection. Any idea why it doesn't keep the change in the drop down box?

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: VBA with IE DropDowns

    Can you post the URL of the site/page?
    If posting code please use code tags, see here.

  5. #5
    Registered User
    Join Date
    10-28-2010
    Location
    Ottawa, Ontario
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: VBA with IE DropDowns

    Not really because it requires a login...which the VBA program is doing. I can provide source code from it if that is helpful? This is the source code related to the dropdown:

    <td width="490px" class="TdLeftLight"><SELECT id=slctMunc name="COUNTY_MUN" class="Form_DropDown" style="width:415px">

    <OPTION value=1134 >Addington Highlands Township (1134)</option>
    <OPTION value=3946 >Adelaide Metcalfe Township (3946)</option>
    <OPTION value=4383 >Adjala-Tosorontio - Tosorontio Cfb Pt (4383)</option>
    <OPTION value=4301 >Adjala-Tosorontio Township (4301)</option>
    <OPTION value=4742 >Admaston/Bromley Township (4742)</option>
    <OPTION value=1805 >Ajax Town (1805)</option>
    <OPTION value=5911 >Alberton Township (5911)</option>
    <OPTION value=0231 >Alfred And Plantagenet Township (0231)</option>
    <OPTION value=4621 >Algonquin Highlands Township (4621)</option>

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: VBA with IE DropDowns

    I'm afraid the source code doesn't help much, especially when it appears there's something going on in the background.)

    Have you tried setting the value instead of the selectedIndex?

    Or looping through all the options and, when you find it, setting the option you want to be selected?

  7. #7
    Registered User
    Join Date
    10-28-2010
    Location
    Ottawa, Ontario
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: VBA with IE DropDowns

    Thank you for looking, much appreciated. I am a VBA hack ... I have tried a few things but not sure how to do either of those options. I have tried:

    .forms("form1").getElementsByTagName("COUNTY_MUN").Value = "0614"

    Which didn't work. How do you set the value?

  8. #8
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: VBA with IE DropDowns

    What happens when you manually select a place/town?

  9. #9
    Registered User
    Join Date
    10-28-2010
    Location
    Ottawa, Ontario
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: VBA with IE DropDowns

    Nothing happens immediately. The dropdown updates to that town, then there are a few more options (toggle buttons etc) and then there is a submit button.

  10. #10
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: VBA with IE DropDowns

    Is it definitely not possible to access the page, or a similar page, without a login?

  11. #11
    Registered User
    Join Date
    10-28-2010
    Location
    Ottawa, Ontario
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: VBA with IE DropDowns

    No but lets do something more simple. www.tirerack.com has a dropdown for Make of car. This is slightly different because there is an onchange event. But if I could see how code works for a similar website I should be able to adapt it.

  12. #12
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: VBA with IE DropDowns

    You never mentioned an onchange event, and it isn't in any of the source code you posted.

    Perhaps you need to trigger the onchange event using code?


    PS Do you know what type of page it is? For example is it ASP, HTML?

  13. #13
    Registered User
    Join Date
    10-28-2010
    Location
    Ottawa, Ontario
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: VBA with IE DropDowns

    I think it is just HTML, not sure how to know. I was suggesting we try to get the code working for tirerack just because the drop downs look similar. Tirerack has the onchange event not the website I am trying to get working.

  14. #14
    Registered User
    Join Date
    10-28-2010
    Location
    Ottawa, Ontario
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: VBA with IE DropDowns

    I am lost, I have tried so many different ways and it still doesn't work. This is what I am trying now for a basic understanding:
    Please Login or Register  to view this content.

  15. #15
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645
    The only way the 2 sites are similar is that they both have dropdown boxes on them.

    As far as I can tell the page/site you are actually interested uses ASP, the other site doesn't.

  16. #16
    Registered User
    Join Date
    10-28-2010
    Location
    Ottawa, Ontario
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: VBA with IE DropDowns

    If that is the case what direction should I go in. After doing a lot of reading there are many ways to make this work. there is document.forms, getelementbyname getelementbyID, value, selectedindex. I have tried many variations with no luck.

  17. #17
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: VBA with IE DropDowns

    document.forms, getelementbyname getelementbyID etc are just different ways to refer to/get references to elements on the page.

    It doesn't matter which one you use.

    selectedIndex should work, and I think in an earlier post you indicate it did, sort of.

    There must be something else going on, probably in the background, perhaps even something that's been set up to prevent people automating the site.

    Without having access to the page it's almost impossible to say for sure what's going on.

  18. #18
    Registered User
    Join Date
    10-28-2010
    Location
    Ottawa, Ontario
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: VBA with IE DropDowns

    Ok, ya it does work, it selects it then immediately puts it back to the default. Ok thank you for your help, I will keep playing with it!!

+ 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. Dropdowns
    By excelinho in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-11-2013, 02:59 PM
  2. Excel 2007 : filtering dropdowns with dropdowns?
    By CADiphile in forum Excel General
    Replies: 2
    Last Post: 10-15-2009, 04:11 PM
  3. Help with dropdowns
    By srs in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-04-2008, 04:57 AM
  4. Dropdowns and possible "sub dropdowns
    By LeonidasSaveUs! in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-01-2008, 09:55 PM
  5. DropDowns
    By Dharsh in forum Excel General
    Replies: 2
    Last Post: 04-28-2005, 08:06 AM

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