View Single Post
 
Old 01-12-2012, 06:17 AM
tinfanide tinfanide is offline Windows 7 64bit Office 2010 32bit
Expert
 
Join Date: Aug 2011
Posts: 312
tinfanide is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
Hi tinfanide,

The document.getElementsByClassName parameter is available in IE9 / HTML5. So, if it's not working on your users' PCs, it would seem that either their IE9 installation is faulty or they don't actually have IE9 installed.
Code:
Option Explicit

Function GetElementsByClassName1(cName As String, q As String)


Dim IE As New InternetExplorer
IE.Visible = True
IE.navigate "http://hk.dictionary.yahoo.com/dictionary?p=" & q
Dim html As HTMLDocument
Set html = IE.Document

Do Until IE.readyState = 4

Loop
    
    Dim Result
    Dim tag
    Dim tags As Object
    Set tags = html.getElementsByTagName("*")

    Result = Array()


    For Each tag In tags
        If tag.className = cName Then
            ReDim Preserve Result(UBound(Result) + 1)
            Set Result(UBound(Result)) = tag
        End If
    Next tag

    GetElementsByClassName1 = Result(0).getElementsByTagName("div")(0).innerText
    
IE.Quit
End Function
GetElementsByClassName.xlsm
Could ya please debug the code for me?
It seems that I cannot pass the arguments directly "strings" (with reference to the error help in Excel)
It's beyond what I know about VBA.
Reply With Quote