For Each rng In ActiveSheet.Range("a1", ActiveSheet.Range("a65536").End(xlUp))
rng.Select
If rng.Value <> "" Then
rng.Select
Set XH = CreateObject("Microsoft.XMLHTTP")
With XH
.Open "get", iurl & rng, False
.send
' On Error Resume Next
'從Yahoo字典摘取第一組中文翻譯
n = .responseText
If InStr(.responseText, "><h4>1.") > 0 Then rng.Offset(0, 2) = Trim(Split(Split(.responseText, "><h4>1.")(1), "<")(0))
'摘取KK音標
If InStr(.responseText, ">KK[") > 0 Then rng.Offset(0, 1) = "[" & Split(Split(.responseText, ">KK[")(1), "]")(0) & "]"
.Open "get", iurl2 & rng, False
.send
'從DICT.TW 英漢字典擷取字義
If InStr(.responseText, "</span><br /> ") > 0 Then rng.Offset(0, 3) = Split(Split(.responseText, "</span><br /> ")(1), "<")(0)
End With
End If
Next
End Sub
複製代碼
作者: 自我感覺良好 時間: 2015-5-30 05:43
回復 3#Hsieh
n = .responseText
If InStr(.responseText, "><h4>1.") > 0 Then rng.Offset(0, 2) = Trim(Split(Split(.responseText, "><h4>1.")(1), "<")(0))
'摘取KK音標
If InStr(.responseText, ">KK[") > 0 Then rng.Offset(0, 1) = "[" & Split(Split(.responseText, ">KK[")(1), "]")(0) & "]"
.Open "get", iurl2 & rng, False
.send
'從DICT.TW 英漢字典擷取字義
If InStr(.responseText, "</span><br /> ") > 0 Then rng.Offset(0, 3) = Split(Split(.responseText, "</span><br /> ")(1), "<")(0)
End With
End If
Next
End Sub
Sub searchIT(rng As Range)
Dim XH As Object
Dim shpRm As Shape
Columns("B:B").Select
With Selection.Font
.Name = "Arial Unicode MS"
.Size = 12
End With
Range("a1").Select
Dim iurl, iurl2 As String
'清除已有的解釋及音標
iurl = "http://tw.dictionary.search.yahoo.com/search?p="
iurl2 = "http://dict.tw/index.pl?query="
For Each rng In ActiveSheet.Range("a1", ActiveSheet.Range("a50").End(xlUp))
rng.Select
If rng.Value <> "" Then
rng.Select
Set XH = CreateObject("Microsoft.XMLHTTP")
With XH
.Open "get", iurl & rng, False
.send
' On Error Resume Next
'從Yahoo字典摘取第一組中文翻譯
If InStr(.responseText, "><h4>1.") > 0 Then rng.Offset(0, 2) = Trim(Split(Split(.responseText, "><h4>1.")(1), "<")(0))
'摘取KK音標
If InStr(.responseText, ">KK[") > 0 Then rng.Offset(0, 1) = "[" & Split(Split(.responseText, ">KK[")(1), "]")(0) & "]"
.Open "get", iurl2 & rng, False
.send
'從DICT.TW 英漢字典擷取字義
If InStr(.responseText, "</span><br /> ") > 0 Then rng.Offset(0, 3) = Split(Split(.responseText, "</span><br /> ")(1), "<")(0)
End With
End If
Next
End Sub作者: brianhau 時間: 2015-12-9 14:43