vba - How to Dim a getElementsBy* result -


i doing internet searching vba, , @ 1 point have line

set valueresult = currpage.getelementbyid("rg_s").getelementsbytagname("img") 

where currpage declared htmldocument

and i'm wondering how dim valueresult achieve:

  1. intellisense (vba's autocomplete) results
  2. better execution times (by using specific rather default variant type)

when @ locals window, i'm told set gives disphtmlelementcollection type, that's not option when dim. i've read getelementsby* returns node list opposed array, i've been trying follow avenue, can't find vba specific.

so how should declare it? - @ moment i've got dim valueresult object that's hardly better variant , doesn't give intellisense prompts.

nb. have microsoft html object library ticked

it should ihtmlelementcollection type.

dim valueresult ihtmlelementcollection  '// code here  set valueresult = currpage.getelementbyid("rg_s").getelementsbytagname("img") 

the getelementsbytagname() method return collection because there potentially multiple matches. getelementbyid() method return element, ihtmlelement


quick example:

sub test()  dim col ihtmlelementcollection dim item ihtmlelement  set ie = createobject("internetexplorer.application")  ie.navigate "http://www.google.co.uk"  while ie.readystate <> 4     doevents wend  set col = ie.document.getelementsbytagname("a")  each in col     set item =     debug.print item.outertext next  ie.quit  end sub 

Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -