![]() |
|
#1
|
|||
|
|||
|
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
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) |
|
|
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 |
Word 2003 document suddenly "locked for editing" by me
|
lisa801 | Word | 3 | 07-08-2011 10:11 PM |
"Table of content" based on "Normal Style" behavior!!!!
|
Jamal NUMAN | Word | 4 | 07-08-2011 04:12 AM |
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 |