0

I have an issue to click link <a href below and That Link is Dynamic, here the script that I've made :

Set Menu_KKPTs = HTMLdoc.getElementsByTagName("a")

For Each Menu_KKPT In Menu_KKPTs
    Menu_KKPT(17).Click
Next Menu_KKPT

and the HTML Code:

<li class="menu-item" jeniswp="">
   <div>KKP</div>
   <a href="//index.php?r=awp/awpargp/kkpt&n=eNpjYGBgEmEWZMkrKC8Q5Dc0MTEws7S0MLM0NDUwMBBkKckoy">
     <i class="icon-doc"></i>
     <span class="title">
     </span>
  </a>
</li>

Thanks for the help!

GSerg
  • 76,472
  • 17
  • 159
  • 346
Mr.New
  • 27
  • 4
  • Look at the answer of @Matteo NNZ: https://stackoverflow.com/questions/47874187/how-to-click-an-href-using-an-excel-vba – pizzettix Jan 28 '21 at 13:54
  • `HTMLDoc.querySelector(".menu-item [href^='//index.php?r=awp/awpargp/kkpt&n=']").click` However, if they all start with the same string then you may need `HTMLDoc.querySelectorAll(".menu-item [href^='//index.php?r=awp/awpargp/kkpt&n=']").item(17).click` where 17 needs to be whatever appropriate number. – QHarr Jan 28 '21 at 14:00
  • You want something that remains static, whether it is the .innerText, some part of the href, the position of the href, or the position of the href relative to another element. Identify that and you have a better chance of coding something likely to last for a while (note I don't specify more than a while :-)) – QHarr Jan 28 '21 at 14:04

0 Answers0