Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #5  
Old 01-12-2012, 07:18 AM
tinfanide tinfanide is offline IE9- "document.getElementsByClassName" problem Windows 7 64bit IE9- "document.getElementsByClassName" problem Office 2010 32bit
Expert
IE9- "document.getElementsByClassName" problem
 
Join Date: Aug 2011
Posts: 312
tinfanide is on a distinguished road
Default

Just fix it.
Code:
Sub WebDictQuery()

Dim x As Integer
Dim Query As String
For x = 1 To 3
   Cells(x, 3).Value = GetElementsByClassName("pronunciation", Cells(x, 1).Value)
Next x

End Sub

Function GetElementsByClassName(className, q)
''''''''''''''''''''''''''''''''''''''''
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
''''''''''''''''''''''''''''''''''''''''
IE.Visible = False
IE.navigate "http://hk.dictionary.yahoo.com/dictionary?p=" & q

Do Until IE.readyState = 4

Loop
    
    Dim Result
    Dim tag
    Dim tags As Object
'''''''''''''''''''''''''''''''''''''''''''''''''''
    Set tags = IE.document.getElementsByTagName("*")
'''''''''''''''''''''''''''''''''''''''''''''''''''
    Result = Array()

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

    GetElementsByClassName = Result(0).getElementsByTagName("div")(0).innerText
    
IE.Quit
''''''''''''''''''''''''''''''''''''
Set IE = Nothing
''''''''''''''''''''''''''''''''''''
End Function
The key is late binding. I might have got it wrong, though. Earlier I used to use early binding for the Internet Explorer Object (don't know if I may get it right or wrong...) It reports an error in the line

Code:
Set html = IE.Document
But when it is set with late binding, nothing wrong happens.
Reply With Quote
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to edit the "Format" and the "show level" of an EXISTING table of content? Jamal NUMAN Word 2 08-14-2011 10:46 AM
IE9- "document.getElementsByClassName" problem Word 2003 document suddenly "locked for editing" by me lisa801 Word 3 07-08-2011 10:11 PM
IE9- "document.getElementsByClassName" problem "Table of content" based on "Normal Style" behavior!!!! Jamal NUMAN Word 4 07-08-2011 04:12 AM
IE9- "document.getElementsByClassName" problem How to choose a "List" for certain "Heading" from "Modify" tool? Jamal NUMAN Word 2 07-03-2011 03:11 AM
"Microsoft Excel Application" missing in the "Component Services" on win08 sword.fish Excel 0 02-26-2010 02:09 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:13 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft