返回列表 上一主題 發帖

上網查音標英英解釋

回復 1# brianhau
用錯的程式碼出現了VB編輯器
這樣我照著試試,成功了

1.  檔案>選項>自訂功能區勾選開發人員,以後就有按鈕直接進去了...
或是快速鍵 Alt+ F11
   
2.  每個網頁都是不一樣的,原程式是針對奇摩字典的網頁分析擷取結果的,你只換網址,分析邏輯都沒變當然不能用...

3.  英英字典的自訂函數
  1. Private oxmlhttp As Object
  2. Private ohtml As Object
  3. Function dictionary_oxford(word As String)
  4.     Dim colNodes As Object, bFound As Boolean
  5.         
  6.     If oxmlhttp Is Nothing Then Set oxmlhttp = CreateObject("msxml2.xmlhttp")
  7.     If ohtml Is Nothing Then Set ohtml = CreateObject("htmlfile")
  8.    
  9.     With oxmlhttp
  10.         .Open "get", "http://www.oxfordlearnersdictionaries.com/definition/english/" & word, False
  11.         .send
  12.         ohtml.body.innerhtml = .responsetext
  13.         
  14.         '<span class="def" ...
  15.         Set colNodes = ohtml.getElementsByTagName("span")
  16.         For Each x In colNodes
  17.             If x.className = "def" Then bFound = True: dictionary_oxford = x.innerText: Exit For
  18.         Next
  19.         If Not bFound Then dictionary_oxford = "# Not Found #"
  20.     End With
  21. End Function
複製代碼
表達不清、題意不明確、沒附檔案格式、沒有討論問題的態度~~~~~~以上愛莫能助。

TOP

回復 3# brianhau
新增新的Module,貼上2# code
工作表 A1 填你要查的字
            B1 填 =dictionary_oxford(A1)

網頁擷取相關的就算是進階書也不會教你的
入門書到書店翻翻看適合自己程度的會比較好。
表達不清、題意不明確、沒附檔案格式、沒有討論問題的態度~~~~~~以上愛莫能助。

TOP

        靜思自在 : 手心向下是助人,手心向上是求人;助人快樂,求人痛苦。
返回列表 上一主題