pull data from website using VBA excel multiple classname

后端 未结 3 1394
梦谈多话
梦谈多话 2020-12-15 13:40

I know this has been asked many times, but haven\'t seen a clear answer for looping thru a div and findind tags with the same classname.

My first question:

3条回答
  •  离开以前
    2020-12-15 14:43

    To print elements to cells replace:

    For Each oElement In oHtml.getElementsByClassName("imageElement")
        Debug.Print oElement.Children(0).src
    Next oElement
    

    With:

    Dim wsTarget as Worksheet
    dim i as Integer
    i=1
    set wsTarget=activeworkbook.worksheets("SomeSheet")
    
    For Each oElement In oHtml.getElementsByClassName("imageElement")
        wstarget.range("A" & i)=oElement.Children(0).src
        i=i+1
    Next
    

    'Corrected the syntax error on For

提交回复
热议问题