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-----
CODE 2-----
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.
Bookmarks