none
Get content of class tag in webpage using VBA RRS feed

  • Question

  • Hi,
    From Below HTML code, i need to retrive "Sign Out" content, pointing class name as reference in Excel - VBA
    ID keep changing in my case, except the class name.
    <span id="ext-gen371" class="x-menu-item-text">Sign Out</span>

    Thanks !
    Thursday, January 17, 2013 10:26 AM

Answers

  • Dim IE As New InternetExplorer
    IE.navigate "Site address"
    IE.Visible = True
    Do
    DoEvents
    Loop Until IE.readyState = READYSTATE_COMPLETE
    Application.Wait (Now() + TimeValue("00:00:016")) ' For internal page refresh or loading
    Dim doc As HTMLDocument 'variable for document or data which need to be extracted out of webpage
    Set doc = IE.document
    Dim dd As Variant
    dd = doc.getElementsByClassName("class name of HTML ")(0).innerText 
    MsgBox dd 

    Above code worked for me.
    • Marked as answer by Sankar AJ Sunday, January 20, 2013 2:54 AM
    Sunday, January 20, 2013 2:54 AM

All replies

  • Hi,
    From Below HTML code, i need to retrive "Sign Out" content, pointing class name as reference in Excel - VBA
    ID keep changing in my case, except the class name.
    <span id="ext-gen371" class="x-menu-item-text">Sign Out</span>

    Thanks !
    Above query is unaswered in other forums too, is it a tough task ?
    Friday, January 18, 2013 4:20 AM
  • Dim IE As New InternetExplorer
    IE.navigate "Site address"
    IE.Visible = True
    Do
    DoEvents
    Loop Until IE.readyState = READYSTATE_COMPLETE
    Application.Wait (Now() + TimeValue("00:00:016")) ' For internal page refresh or loading
    Dim doc As HTMLDocument 'variable for document or data which need to be extracted out of webpage
    Set doc = IE.document
    Dim dd As Variant
    dd = doc.getElementsByClassName("class name of HTML ")(0).innerText 
    MsgBox dd 

    Above code worked for me.
    • Marked as answer by Sankar AJ Sunday, January 20, 2013 2:54 AM
    Sunday, January 20, 2013 2:54 AM
  • You are te fucking best!!!!!! Thanks :,)
    Friday, August 16, 2013 8:01 AM