+ Reply to Thread
Results 1 to 4 of 4

How to click Unordered List in IE using VBA

  1. #1
    Registered User
    Join Date
    09-01-2017
    Location
    India
    MS-Off Ver
    2013
    Posts
    4

    Question How to click Unordered List in IE using VBA

    Hello Everyone,

    This is my first post at Excel Help Forum. But I have been benefited greatly by the posts in this forum. So, sincere thanks to all of you.

    Now, I have an unordered list with links in IE and the list is also dynamic. Clicking on the 1st level in the list will open the 2nd level and so on. My work is to select one link within 4th level. So I have to click up to 4th level and click another option after that.

    I have attached the initial html code of the unordered list in image 'initial_html' and the html code of the unordered list after clicking "GENERAL" (1st level) in image 'afterclick_html'. Both the 1st and 2nd level in the unordered list have the same name 'GENERAL'.

    To click 1st level, I tried writing two kinds of codes,

    CODE 1-----

    Please Login or Register  to view this content.
    CODE 2-----

    Please Login or Register  to view this content.
    Now these are my questions,

    1. Assuming my CODE 1 is correct, I am able to select my 1st level through innerText 'General'. But my 2nd level also has the same innerText 'General'. So how do I specify in code that it is the 2nd level.

    2. Also, in CODE 1, I have used cLinks.click. Is it correct or should I use cLinks.FireEvent("onclick")?

    3. Now in CODE 2, I have declared cLinks As MSHTML.HTMLLIElement. But I am not using any <li> tag in the code. So what should I declare it as, as MSHTML.HTMLLIElement or as MSHTML.HTMLElement?

    Finally, is CODE 1 and CODE 2 correct pertaining to my unordered list? I cannot execute my code and check now as I have to go to my office to do that.

    So what do you think? Which one is suitable? I think CODE 2 would be appropriate for all the levels in the unordered list. If both the codes are wrong, can you suggest a suitable one?

    Sorry for the very long post, I am just learning web-scraping using VBA so I am full of doubts for which I am not able to find solutions on the internetinitial.JPGafterclick.JPG.

    Can anyone please help? Thanks in advance.

  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: How to click Unordered List in IE using VBA

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

  3. #3
    Registered User
    Join Date
    09-01-2017
    Location
    India
    MS-Off Ver
    2013
    Posts
    4
    Quote Originally Posted by Norie View Post
    Can you post the URL?
    It is an intranet URL. So it's not going to be helpful..

  4. #4
    Registered User
    Join Date
    09-01-2017
    Location
    India
    MS-Off Ver
    2013
    Posts
    4

    Re: How to click Unordered List in IE using VBA

    Can you suggest any suitable code? My code doesn't seem to do anything..

+ 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. button click to move selected multi-column list box items to new list box
    By kranic3 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-14-2017, 08:34 AM
  2. [SOLVED] HTML Unordered List Display Issues Outlook vs Internet Explorer
    By rkl303 in forum Outlook Programming / VBA / Macros
    Replies: 2
    Last Post: 08-26-2015, 10:10 AM
  3. Match up between two excel sheets having unordered data
    By pkdash83 in forum Excel General
    Replies: 3
    Last Post: 02-21-2011, 07:28 AM
  4. Multi-column Matching For Unordered Vlookup
    By bernborough in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-29-2010, 03:39 AM
  5. Replies: 1
    Last Post: 04-16-2010, 03:50 AM
  6. VBA lookup functions: unordered list
    By Dave32 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-03-2008, 10:14 PM
  7. Replies: 8
    Last Post: 01-04-2006, 12:10 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