Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #6  
Old 01-13-2012, 12:43 AM
macropod's Avatar
macropod macropod is offline IE9- "document.getElementsByClassName" problem Windows 7 64bit IE9- "document.getElementsByClassName" problem Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,521
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi tinfanide,

I'm not familiar with IE automation. However, when I test your funnction with:
Code:
Sub Test()
GetElementsByClassName1 "pronunciation", "dog"
End Sub
it fails every time at 'Set html = IE.Document' with the error message "Runtime Error '2147467259 (80004005)': / Automation Error / Unspecified Error". You can fix that by moving the
'Set html = IE.Document' after the 'Loop' line. Speaking of which your 'Do Until ... Loop' should have a 'DoEvents' statement, like:
Code:
Do Until IE.readyState = READYSTATE_COMPLETE
  DoEvents
Loop
After moving the 'Set html = IE.Document' line, the code runs to completion OK, but there is still no sound - which is what I gather you're intending to get.

Your code would also be more efficient with:
Code:
Result = Array(0)
For Each tag In tags
  If tag.className = cName Then
    Set Result(0) = tag
    Exit For
  End If
Next tag
GetElementsByClassName1 = Result(0).getElementsByTagName("div")(0).innerText
and even moreso if you dispense with the array:
Code:
For Each tag In tags
  If tag.className = cName Then
    GetElementsByClassName1 = tag.getElementsByTagName("div")(0).innerText
    Exit For
  End If
Next tag
None of which resolves the underlying problem, but might help with the project overall.

PS: I'm moving the thread to the Excel forum, as you've posted in the Word vba forum and your attachment shows this is really for Excel.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
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 10:42 AM.


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