+ Reply to Thread
Results 1 to 10 of 10

Select option in HTML drop down list

  1. #1
    Registered User
    Join Date
    04-14-2014
    Location
    Toronto
    MS-Off Ver
    Excel 2007
    Posts
    6

    Select option in HTML drop down list

    Hi all, this has been puzzling me for a day. What I want to do is select other options in IE html drop down list. But somehow the other methods I read online doesn't work with my situation. I got either "Variable or Block Variable not set yet" or "Property or Method doesn't apply" errors. The following is the VBA code I have so far:

    Please Login or Register  to view this content.
    and the following is html code of the web page:

    HTML Code: 
    I tried IE.document.getElementByName("dxr_report").Value = "file2" to choose the file2 but failed
    I also tried IE.document.all.Item("dxr_report").Vaule = "file2", doesn't work either.

    Any Idea? Please help! Thanks in advance
    Last edited by JohnsonJiang; 04-15-2014 at 01:35 PM.

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

    Re: Select option in HTML drop down list

    Try getElementsByName("dxr_report")(0) to get the element and use selectedIndex to make the selection.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    04-14-2014
    Location
    Toronto
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Select option in HTML drop down list

    Do you mean like this:

    Please Login or Register  to view this content.
    It doesn't work....I'm New to VBA coding so please forgive if this is dumb Thanks
    Last edited by JohnsonJiang; 04-15-2014 at 11:39 AM.

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

    Re: Select option in HTML drop down list

    Doesn't work in what way?

    Errors? Nothing happens?

  5. #5
    Registered User
    Join Date
    04-14-2014
    Location
    Toronto
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Select option in HTML drop down list

    It highlighted the

    Please Login or Register  to view this content.
    and pops up message :"Object variable or With block variable not set"

    Could you please check if my newly added code is correct? If so, any idea why the error message come up?

    Thanks a lot for your quick reply

  6. #6
    Registered User
    Join Date
    04-14-2014
    Location
    Toronto
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Select option in HTML drop down list

    Anyone? Please help

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    The way you've written the code is fine but I can't check it as I can't access the URL in your code.

  8. #8
    Registered User
    Join Date
    04-14-2014
    Location
    Toronto
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Select option in HTML drop down list

    That is a private company site so I'm not suprise.
    I've pasted the HTML code with my original post, hope that hleps.

    Question, does it require specific reference to have selectedIndex work? Do I need to define it? I'm not familiar with the selectedIndex so please advice.

    Also, I see there has method like IE.document.getElementByTagName("select")("dxr_report").value = "file2", but I still get the same error message. Do you have any suggestion?

    Thanks a lot for your reply

  9. #9
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    The problem isn't with selectedIndex, it's caused by the object, ie the dropdown, not being found.

    That could be happening for a number of reasons.

    For example you could be dealing with a page made up of frames and the dropdown is in one of the frames, not the main document.

  10. #10
    Registered User
    Join Date
    04-14-2014
    Location
    Toronto
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Select option in HTML drop down list

    I think you might be right about the frame.

    It's a drop down of file name which actually lead to viewing the file in webpage. It'll take extra step to export/download the file.

    Any suggestion on how to select in this case?

+ 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. Replies: 4
    Last Post: 02-07-2014, 12:49 AM
  2. [SOLVED] If I select an option from a drop-down in 1 cell, how do i get it to display specific info
    By Posthuman in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-05-2012, 01:45 PM
  3. Can only select a drop down option once
    By davidstokes in forum Excel General
    Replies: 27
    Last Post: 02-22-2012, 09:55 AM
  4. Replies: 3
    Last Post: 02-02-2012, 12:18 PM
  5. Replies: 5
    Last Post: 10-27-2005, 01:55 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