Option Explicit
Sub IEBrowser()
'https://youtu.be/XbhtQA6q6CY
'https://referencesource.microsoft.com/#System.Web/Configuration/BrowserCapabilitiesFactory.cs,875f9347ad596360
'https://www.google.com/search?q=CreateObject(%22internetexplorer.application%22)&rlz=1C1JRYI_zh-twTW717TW718&oq=CreateObject(%22internetexplorer.application%22)&aqs=chrome..69i57.5602j0j7&sourceid=chrome&ie=UTF-8
Dim whatWhere As String, rw As Long, URL As String
rw = ActiveCell.Row
If ActiveCell.Column > 1 Then
Cells(rw, 1).Select
End If
whatWhere = ActiveCell.Value
Select Case whatWhere
Case "查詢《國語辭典》"
URL = Range("c1").Value
If URL = "" Then URL = "http://dict.revised.moe.edu.tw/cbdic/search.htm"
Case Else
Exit Sub
End Select
With CreateObject("internetexplorer.application")
.navigate URL
Do While .Busy Or .readyState <> 4
DoEvents
Loop
'DOM物件文件物件模型(Document Object Model, DOM)是HTML、XML 和SVG 文件的程式介面。
With .document
Select Case whatWhere
Case "查詢《國語辭典》"
.all("qs0").Value = Range("b" & rw).Value '.all是IE專用的方法
.all("button").Click
Case Else
Exit Sub
End Select
End With
.Visible = True
End With
End Sub
'http://forum.twbts.com/viewthread.php?tid=10377
'Chrome:
'https://www.google.com/search?rlz=1C1JRYI_zh-twTW717TW718&sxsrf=ACYBGNRGnMYUxCpRkh5EHvYqUn1OiP49ug%3A1573272750353&ei=rjzGXfSeFeyUr7wPiOCK6Ao&q=createobject%28+chrome.application+%29&oq=CreateObject%28%22chro.application%22%29&gs_l=psy-ab.1.0.0i7i30i19l3j0i8i7i30i19l2j0i7i5i30i19l5.19331.21442..23170...0.0..0.80.260.4......0....1..gws-wiz.......0i7i30j0i8i7i30.KIl85BnsB28
'https://community.smartbear.com/t5/TestComplete-Functional-Web/How-do-I-get-a-web-element-from-Chrome-browser-using-VBScript-I/td-p/156766
'https://tomyam-yang.blogspot.com/2015/09/vbsgoogle-chromeie.html