Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 01-11-2012, 07:15 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 IE9- "document.getElementsByClassName" problem


Code:
Function w(cName As String, q As String)

On Error Resume Next
Dim IE As New InternetExplorer
IE.Visible = False
IE.navigate "http://hk.dictionary.yahoo.com/dictionary?p=" & q
Do
DoEvents
Loop Until IE.readyState = READYSTATE_COMPLETE
Dim html As HTMLDocument
Set html = IE.document

Dim y As Integer
y = -1

Do Until y > html.getElementsByTagName("div").Length
    y = y + 1
    If html.getElementsByTagName("div")(y).ClassName = cName Then _
      
       w = html.getElementsByTagName("div")(y).innerText
    End If
Loop

IE.Quit
On Error GoTo 0


End Function
Well, I've originally written a set of VBA codes with the use of "document.getElementsByClassName" but it does not work in my users' computers on which they've installed IE9- (mine is IE9)

I thought ClassName only works in IE9 so I tweaked the code above a bit and hoped to have a workaround. It works. It is far from perfect, though.
(Use of "document.getElementsByClassName" can save me work on looping the tags to find where the classname is.

I wonder if there's a direct approach for it. (I can do it in JS but very good in VB)
Reply With Quote
 



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 11:14 PM.


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