ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

¤Wºô¬d­µ¼Ð­^­^¸ÑÄÀ

¤Wºô¬d­µ¼Ð­^­^¸ÑÄÀ

­è­èª¦¤F¤@¤U¤å
¥Î¿ùªºµ{¦¡½X¥X²{¤FVB½s¿è¾¹
³o¼Ë§Ú·ÓµÛ¸Õ¸Õ¡A¦¨¥\¤F


½Ð±Ð«e½ú­Y¬O§Ú·Q­n´¡¤J¤@ÄæÂ^¨ú­^­^ªº¸ÑÄÀ­n«ç»ò°µ©O¡H
¨Ò¦p±q
http://www.oxfordlearnersdictionaries.com/definition/english/?q=
¤¤Â^¨ú²Ä¤@¦æ­^­^¸ÑÄÀ


§Ú¸ÕµÛ§ï°Êµ{¦¡½X¦ý¨S¦³¥ô¦ó¤ÏÀ³
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
    '²M°£¤w¦³ªº¸ÑÄÀ¤Î­µ¼Ð
    iurl = "http://www.oxfordlearnersdictionaries.com/definition/english/?q="
    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
                        '±qYahoo¦r¨åºK¨ú²Ä¤@²Õ¤¤¤å½Ķ
                    
                         If InStr(.responseText, "><h4>1.") > 0 Then rng.Offset(0, 2) = Trim(Split(Split(.responseText, "><h4>1.")(1), "<")(0))
                        'ºK¨úKK­µ¼Ð
                        If InStr(.responseText, ">KK[") > 0 Then rng.Offset(0, 1) = "[" & Split(Split(.responseText, ">KK[")(1), "]")(0) & "]"
                        .Open "get", iurl2 & rng, False
                        .send
                        '±qDICT.TW ­^º~¦r¨åÂ^¨ú¦r¸q
                        If InStr(.responseText, "</span><br /> &nbsp;") > 0 Then rng.Offset(0, 3) = Split(Split(.responseText, "</span><br /> &nbsp;")(1), "<")(0)
                    End With
             End If
    Next
End Sub

§Ú¥Î¤W­±ªºµ{¦¡½X,¤W©P¤j³¡¥÷³£¥i¦¨¥\,¦ý±q¤W©P¤»¶}©l¥X²{¿ù»~°T®§,Run-time error '1004",½Ð°Ý°ª¤â,¦³¦n¤èªk¶Ü? ¤U­±¤G­Ó¥­¥xª©¥»,¥X²{ªºª¬ªp³£¤@¼Ë

Windows 7+office 2010
Windows 10+office 2010

TOP

¦^´_ 11# c_c_lai


    ·PÁ¡I¯uªº«D±`·PÁ§A¡I
¦¨¥\¤F¡I
§Ú·Q±z»¡ªº«Ü²M·¡¡A¦ý§Ú¬Ý¤£¤jÀ´¡A»Ý­n¦n¦n®ø¤Æ¤@µf¡I

TOP

¦^´_ 8# brianhau
  1. Option Explicit

  2. Private oxmlhttp As Object
  3. Private ohtml As Object

  4. Sub Ex()
  5.     Dim txt As String
  6.    
  7.     '  txt = dictionary_oxford("simulation")
  8.     '  MsgBox "simulation = " & txt
  9.     '  searchITA ([A1])
  10.     searchIT ([A1])
  11. End Sub

  12. Function dictionary_oxford(word As String)
  13.     Dim colNodes As Object, bFound As Boolean, x As Variant
  14.         
  15.     If oxmlhttp Is Nothing Then Set oxmlhttp = CreateObject("msxml2.xmlhttp")
  16.     If ohtml Is Nothing Then Set ohtml = CreateObject("htmlfile")
  17.    
  18.     With oxmlhttp
  19.         .Open "get", "http://www.oxfordlearnersdictionaries.com/definition/english/" & word, False
  20.         .send
  21.         ohtml.body.innerhtml = .responseText
  22.         
  23.         '  <span class="def" ...
  24.         Set colNodes = ohtml.getElementsByTagName("span")
  25.         For Each x In colNodes
  26.             If x.className = "def" Then bFound = True: dictionary_oxford = x.innerText: Exit For
  27.         Next
  28.         If Not bFound Then dictionary_oxford = "# Not Found #"
  29.     End With
  30. End Function

  31. Function searchIT(rng As Range)
  32.     Dim XH As Object, shpRm As Shape
  33.     Dim iurl, iurl2 As String
  34.      
  35.     Columns("B:B").Select
  36.     With Selection.Font
  37.          .Name = "Arial Unicode MS"
  38.          .Size = 12
  39.     End With
  40.    
  41.     Range("B:J").Clear
  42.     '  Range("a1").Select
  43.     rng.Select
  44.     '  ²M°£¤w¦³ªº¸ÑÄÀ¤Î­µ¼Ð
  45.     iurl = "http://tw.dictionary.search.yahoo.com/search?p="
  46.     iurl2 = "http://dict.tw/index.pl?query="
  47.     For Each rng In ActiveSheet.Range("a1", ActiveSheet.Range("A" & Rows.Count).End(xlUp))
  48.         rng.Select
  49.         If rng.Value <> "" Then
  50.             rng.Select
  51.             Set XH = CreateObject("Microsoft.XMLHTTP")
  52.             With XH
  53.                 .Open "get", iurl & rng, False
  54.                 .send
  55.                 '  On Error Resume Next
  56.                 '  ±qYahoo¦r¨åºK¨ú²Ä¤@²Õ¤¤¤å½Ķ
  57.                 '  rng.Offset(0, 20) = .responseText
  58.                 rng.Offset(0, 20) = ""
  59.                 If InStr(.responseText, "><h4>1.") > 0 Then rng.Offset(0, 2) = Trim(Split(Split(.responseText, "><h4>1.")(1), "<")(0))
  60.                 '  ºK¨úKK­µ¼Ð
  61.                 If InStr(.responseText, ">KK[") > 0 Then rng.Offset(0, 1) = "[" & Split(Split(.responseText, ">KK[")(1), "]")(0) & "]"
  62.                 .Open "get", iurl2 & rng, False
  63.                 .send
  64.                 '  ±qDICT.TW ­^º~¦r¨åÂ^¨ú¦r¸q
  65.                 If InStr(.responseText, "</span><br /> &nbsp;") > 0 Then rng.Offset(0, 3) = Split(Split(.responseText, "</span><br /> &nbsp;")(1), "<")(0)
  66.             End With
  67.             rng.Offset(0, 9) = dictionary_oxford(rng.Value)
  68.         End If
  69.     Next
  70. End Function

  71. Function searchITA(rng As Range)
  72.     Dim XH As Object, shpRm As Shape
  73.     Dim iurl, iurl2 As String, x As Variant
  74.     Dim colNodes As Object, bFound As Boolean, oxford As String
  75.      
  76.     Columns("B:B").Select
  77.     With Selection.Font
  78.          .Name = "Arial Unicode MS"
  79.          .Size = 12
  80.     End With
  81.     '  ²M°£¤w¦³ªº¸ÑÄÀ¤Î­µ¼Ð
  82.     Range("B:J").Clear
  83.     '  Range("a1").Select
  84.     rng.Select
  85.      
  86.     iurl = "http://tw.dictionary.search.yahoo.com/search?p="
  87.     iurl2 = "http://dict.tw/index.pl?query="
  88.     For Each rng In ActiveSheet.Range("a1", ActiveSheet.Range("A" & Rows.Count).End(xlUp))
  89.         rng.Select
  90.         If rng.Value <> "" Then
  91.             rng.Select
  92.             Set XH = CreateObject("Microsoft.XMLHTTP")
  93.             With XH
  94.                 .Open "get", iurl & rng, False
  95.                 .send
  96.                 '  On Error Resume Next
  97.                 '  ±qYahoo¦r¨åºK¨ú²Ä¤@²Õ¤¤¤å½Ķ
  98.                 If InStr(.responseText, "><h4>1.") > 0 Then rng.Offset(0, 2) = Trim(Split(Split(.responseText, "><h4>1.")(1), "<")(0))
  99.                 '  ºK¨úKK­µ¼Ð
  100.                 If InStr(.responseText, ">KK[") > 0 Then rng.Offset(0, 1) = "[" & Split(Split(.responseText, ">KK[")(1), "]")(0) & "]"
  101.                 .Open "get", iurl2 & rng, False
  102.                 .send
  103.                 '  ±q DICT.TW ­^º~¦r¨åÂ^¨ú¦r¸q
  104.                 If InStr(.responseText, "</span><br /> &nbsp;") > 0 Then rng.Offset(0, 3) = Split(Split(.responseText, "</span><br /> &nbsp;")(1), "<")(0)
  105.             End With
  106.             If oxmlhttp Is Nothing Then Set oxmlhttp = CreateObject("msxml2.xmlhttp")
  107.             If ohtml Is Nothing Then Set ohtml = CreateObject("htmlfile")
  108.    
  109.             With oxmlhttp
  110.                 .Open "get", "http://www.oxfordlearnersdictionaries.com/definition/english/" & rng, False
  111.                 .send
  112.                 ohtml.body.innerhtml = .responseText
  113.         
  114.                 '  <span class="def" ...
  115.                 Set colNodes = ohtml.getElementsByTagName("span")
  116.                 For Each x In colNodes
  117.                     If x.className = "def" Then bFound = True: oxford = x.innerText: Exit For
  118.                 Next
  119.                 If Not bFound Then oxford = "# Not Found #"
  120.            End With
  121.            rng.Offset(0, 9) = oxford
  122.         End If
  123.     Next
  124. End Function
½Æ»s¥N½X

TOP

¦^´_ 8# brianhau
¦p«e­±©Ò­z¡A§A¥i¥H¿ï¾Ü°õ¦æ
(A) searchIT ([A1]) ¥ç©Î¬O
(B) searchITA ([A1])¡C

(A) ¼Ò¦¡«Y±N¨ç¥Ü¤À¬°¨â­Ó¨ç¦¡³B¸Ì¤£¦P¤º®e¡G
    A-1.  Function searchIT(rng As Range)
          ±q Yahoo ¦r¨åºK¨ú²Ä¤@²Õ KK ­µ¼Ð¡B¤¤¤å½Ķ
    A-2.  Function dictionary_oxford(word As String)
          §ì¨ú¹ïÀ³¤§¤û¬z­^Ãã¸ÑÄÀ¡C
(B) ¼Ò¦¡«Y±N¨ç¥Ü¦X¦Ó¬°¤@¡A¥H¤@­Ó¨ç¦¡³B¸Ì A-1 ¥H¤Î A-2
    ¤£¦P§@·~¤º®e¡G
    B.  Function searchITA(rng As Range)

¾Ü¤@°õ¦æ¡A¥i¨Ì§A­Ó¤H³ß¦n¿ï¾Ü¡AA ®×«Y¨Ì³B¸Ì¤£¦P¤º®e¡A¦Ó
¦³¨ä¦U¦Ûªº¨ç¦¡¥]¸Ë¡A¨Æ«á¥i¨Ì¨ä¥¦¹ê°È»Ý¨D©ö©ó²Õ¦X¥]¸Ë¡F
B ®×«Y¬°¾ã¦X¦¡¨ç¦¡¡C)

§A¥i±Nµ{¦¡¥þ³¡¸m©ñ©ó¡y¼Ò²Õ -> Module1¡z¤º¡A©Î¬O±N Ex()
³æ¿W©â¥X¨Ó¥t©ñ¸m¦b ThisWorkbook ªºµ{¦¡½X°Ï¤º¡F©ÎªÌ¬O
±N©Ò¦³µ{¦¡½X¥þ³¡¸Ë¸m¦b  ThisWorkbook ªºµ{¦¡½X°Ï¤º¡C

¦bµ{¦¡½X³Ì«e­±¦pªG§A¥[¤J¤F ¡yOption Explicit¡z¡A
·N§Y§A«Å§i¤F©Ò¦³¨Ï¥Î¤§ÅܼƻÝÀ³¡u¨Æ¥ý¥[¥H«Å§i¡vªº­ì¦]¡C
¦]¬°¦b dictionary_oxford ¨ç¦¡¨Ã¥¼«Å§i x ªºÅܼƫ¬ºA¡A
§A¥u­n¥[¤J«¬ºA«Å§i (x As Variant) §Y¥i¡C

TOP

¦^´_ 8# brianhau
§A¥Ø«eªº¡y¼Ò²Õ¡z¤À§O¬° Module1¡BModule2¡BModule3¡A
¥H¤U¬O§A¥Ø«eµ{¦¡©ñ¸mªº¤º®e¡G
Module1 Â\©ñªº¬O Function dictionary_oxford(word As String)¡A
Module2 Â\©ñªº¬O Sub Ex() ´ú¸Õ¼Ò²Õ (¥Dµ{¦¡)¡A
Module3 Â\©ñªº¬O Function searchIT(rng As Range)
§A¥u­n°õ¦æ ¡y¼Ò²Õ -> Module2 -> Ex¡z´N¦æ¤F¡C
©ÎªÌ¬O (¥¿¦¡¹B§@®É)
§A¥i¥H´¡¤J¡yButton¡zª«¥ó¡A«ü¨ì§Aªº ¡y¼Ò²Õ -> Module2 -> Ex¡z¡C

TOP

¦^´_ 6# c_c_lai
ÁÂÁÂc_c_lai¡A«D±`·P¿E¡I
§Ú¸ÕµÛ¶K¤Wµ{¦¡½X¡Aµo²{§¹¥þ¤£·|°Ê§@¡A¬O¤í¯Ê¤°»ò¨BÆJ¶Ü¡H
¦A¦¸ÁÂÁ±z¡I
dict Eng.rar (12.03 KB)

TOP

¦^´_ 4# stillfish00
ÁÂÁÂstillfish00ªº¦^ÂÐ
¦ý§ÚÁÙ¸Õ¸Õ¤£¥X¨Ó...

TOP

¥»©«³Ì«á¥Ñ c_c_lai ©ó 2015-12-14 07:33 ½s¿è

¦^´_ 3# brianhau
¥ç¥i¥H´©¥Î­ì¥»ªº¤è¦¡¡A§Y
¨Ï¥Î¤À§O¤§¨â­Ó¦Û­q¨ç¦¡¡G
  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
½Æ»s¥N½X
  1. Sub Ex()
  2.     Dim txt As String
  3.    
  4.     '  txt = dictionary_oxford("simulation")
  5.     '  MsgBox "simulation = " & txt
  6.     searchIT ([A1])
  7. End Sub
½Æ»s¥N½X
  1. Function searchIT(rng As Range)
  2.     Dim XH As Object, shpRm As Shape
  3.     Dim iurl, iurl2 As String
  4.      
  5.     Columns("B:B").Select
  6.     With Selection.Font
  7.          .Name = "Arial Unicode MS"
  8.          .Size = 12
  9.     End With
  10.    
  11.     Range("B:J").Clear
  12.     Range("a1").Select
  13.     '  ²M°£¤w¦³ªº¸ÑÄÀ¤Î­µ¼Ð
  14.     iurl = "http://tw.dictionary.search.yahoo.com/search?p="
  15.     iurl2 = "http://dict.tw/index.pl?query="
  16.     For Each rng In ActiveSheet.Range("a1", ActiveSheet.Range("a50").End(xlUp))
  17.         rng.Select
  18.         If rng.Value <> "" Then
  19.             rng.Select
  20.             Set XH = CreateObject("Microsoft.XMLHTTP")
  21.             With XH
  22.                 .Open "get", iurl & rng, False
  23.                 .send
  24.                 '  On Error Resume Next
  25.                 '  ±qYahoo¦r¨åºK¨ú²Ä¤@²Õ¤¤¤å½Ķ
  26.                 If InStr(.responseText, "><h4>1.") > 0 Then rng.Offset(0, 2) = Trim(Split(Split(.responseText, "><h4>1.")(1), "<")(0))
  27.                 '  ºK¨úKK­µ¼Ð
  28.                 If InStr(.responseText, ">KK[") > 0 Then rng.Offset(0, 1) = "[" & Split(Split(.responseText, ">KK[")(1), "]")(0) & "]"
  29.                 .Open "get", iurl2 & rng, False
  30.                 .send
  31.                 '  ±qDICT.TW ­^º~¦r¨åÂ^¨ú¦r¸q
  32.                 If InStr(.responseText, "</span><br /> &nbsp;") > 0 Then rng.Offset(0, 3) = Split(Split(.responseText, "</span><br /> &nbsp;")(1), "<")(0)
  33.             End With
  34.             rng.Offset(0, 9) = dictionary_oxford(rng.Value)
  35.         End If
  36.     Next
  37. End Function
½Æ»s¥N½X
¦p¦¹µ²ªGÀ³¸Ó¬O§Aºc·Qªº¤è¦¡¤F¡C

TOP

¥»©«³Ì«á¥Ñ c_c_lai ©ó 2015-12-12 07:51 ½s¿è

¦^´_ 3# brianhau
§Ú±N§Aªºµ{¦¡»P stillfish00 ¤j¤jªºµ{¦¡½X
²¤¥[¾ã¦X¦¨§Aªº»Ý¨D¡G
  1. Private oxmlhttp As Object
  2. Private ohtml As Object

  3. Function searchITA(rng As Range)
  4.     Dim XH As Object, shpRm As Shape
  5.     Dim iurl, iurl2 As String
  6.     Dim colNodes As Object, bFound As Boolean, oxford As String
  7.      
  8.     Columns("B:B").Select
  9.     With Selection.Font
  10.          .Name = "Arial Unicode MS"
  11.          .Size = 12
  12.     End With
  13.     '  ²M°£¤w¦³ªº¸ÑÄÀ¤Î­µ¼Ð
  14.     Range("B:J").Clear
  15.     Range("a1").Select
  16.      
  17.     iurl = "http://tw.dictionary.search.yahoo.com/search?p="
  18.     iurl2 = "http://dict.tw/index.pl?query="
  19.     For Each rng In ActiveSheet.Range("a1", ActiveSheet.Range("a50").End(xlUp))
  20.         rng.Select
  21.         If rng.Value <> "" Then
  22.             rng.Select
  23.             Set XH = CreateObject("Microsoft.XMLHTTP")
  24.             With XH
  25.                 .Open "get", iurl & rng, False
  26.                 .send
  27.                 '  On Error Resume Next
  28.                 '  ±qYahoo¦r¨åºK¨ú²Ä¤@²Õ¤¤¤å½Ķ
  29.                  If InStr(.responseText, "><h4>1.") > 0 Then rng.Offset(0, 2) = Trim(Split(Split(.responseText, "><h4>1.")(1), "<")(0))
  30.                 '  ºK¨úKK­µ¼Ð
  31.                 If InStr(.responseText, ">KK[") > 0 Then rng.Offset(0, 1) = "[" & Split(Split(.responseText, ">KK[")(1), "]")(0) & "]"
  32.                 .Open "get", iurl2 & rng, False
  33.                 .send
  34.                 '  ±q DICT.TW ­^º~¦r¨åÂ^¨ú¦r¸q
  35.                 If InStr(.responseText, "</span><br /> &nbsp;") > 0 Then rng.Offset(0, 3) = Split(Split(.responseText, "</span><br /> &nbsp;")(1), "<")(0)
  36.             End With
  37.             If oxmlhttp Is Nothing Then Set oxmlhttp = CreateObject("msxml2.xmlhttp")
  38.             If ohtml Is Nothing Then Set ohtml = CreateObject("htmlfile")
  39.    
  40.             With oxmlhttp
  41.                 .Open "get", "http://www.oxfordlearnersdictionaries.com/definition/english/" & rng, False
  42.                 .send
  43.                 ohtml.body.innerhtml = .responseText
  44.         
  45.                 '  <span class="def" ...
  46.                 Set colNodes = ohtml.getElementsByTagName("span")
  47.                 For Each x In colNodes
  48.                     If x.className = "def" Then bFound = True: oxford = x.innerText: Exit For
  49.                 Next
  50.                 If Not bFound Then oxford = "# Not Found #"
  51.            End With
  52.            rng.Offset(0, 9) = oxford
  53.         End If
  54.     Next
  55. End Function
½Æ»s¥N½X
  1. Sub Ex()
  2.     searchITA ([A1])
  3. End Sub
½Æ»s¥N½X

TOP

        ÀR«ä¦Û¦b : ¤H¨ÆªºÁ}Ãø»PµZ¿i¡A´N¬O¤@ºØ¦ÒÅç¡C
ªð¦^¦Cªí ¤W¤@¥DÃD