excel - Click all checkboxes on website -


i have (in excel, vba) sub navigate webpage:

http://www.nordea.dk/wemapp/currency/dk/valutakurser

and copy quoted rates. however, remove rates, , add ones sub needs.

to this, need check of boxes (to left in table), number of boxes not constant - can't hardcode boxnames.

i suppose 1 way extract entire html, determine number of rows, , loop. seems unhandy. surely there smatter way, requires less code , less storage?

you can split() table vbnewline , search currency in each row of set (mind headers).
since inputs named table:body:rows:2:cells:1:cell:check can match currency checkbox.
in practice looks (up getting element names):

function firstrow(myarray() string, optional curr string) long if curr = ""     curr = "*[a-z][a-z][a-z]/[a-z][a-z][a-z]*" else     curr = "*" & curr & "*" end if  = lbound(myarray) ubound(myarray)     if myarray(i) curr 'fx denoted "xxx/xxx"         firstrow =         exit function     end if next end function sub ert() dim myarray() string, urlstr string urlstr = "http://www.nordea.dk/wemapp/currency/dk/valutakurser"  set ie = createobject("internetexplorer.application") ie.visible = false ie.navigate urlstr  until (ie.readystate = 4 , not ie.busy)     doevents loop  on error goto err: data = ie.document.body.innerhtml 'innertext  if false err:     data = ie.document.body.innerhtml end if  myarray = split(data, "<tr>") 'vbnewline) 'vbcrlf)  'for = lbound(myarray) ubound(myarray) '    cells(i + 1, 1).value2 = myarray(i) 'next  dim curr() string redim curr(2)     curr(0) = "dkk/nok"     curr(1) = "eur/sek"     curr(2) = "usd/chf" = lbound(curr) ubound(curr)     x = firstrow(myarray, curr(i)) - firstrow(myarray) + 1     msgbox "table:body:rows:" & x & ":cells:1:cell:check" next ie.quit set ie = nothing end sub 

i'm sorry, vbnewline won't cut time, bad. also, checking named element shouldn't hard, had provided snipplet checking boxes have given shot.


Comments