如何从IE到XL获取ElementsByClassName

时间:2016-06-11 13:32:01

标签: excel internet-explorer getelementsbyclassname

我在这段代码中使用getelementsbyclassname得到错误,并希望得到一些关于我做错的提示。我成功使用了getelementbyID,但classname总是给我错误。

Set objExplorer = CreateObject("InternetExplorer.Application")
WebSite = "http://charting.nasdaq.com/ext/charts.dll?2-1-14-0-0-512-03NA000000ABT-&SF:1|8|27-SH:8=200|

27=10-BG=FFFFFF-BT=0-WD=635-HT=395--XTBL-"
WScript.Sleep 1000
With objExplorer
    .Navigate2 WebSite
    .Left=5
    .Top=5
    .Height=1000
    .Width=700
    .AddressBar = 0
    .Visible = 1
    .ToolBar = 0
    .StatusBar = 0
   WScript.Sleep 3000
End With

Set xl = CreateObject("Excel.Application")
    xl.Visible = True
Set wb = xl.Workbooks.Open("C:\Users\user\Documents\CI\testauto.xlsx")
Set ws = wb.Sheets("Sheet1")
WScript.Sleep 2000

ws.Range("G9").Value = objExplorer.document.getElementsByClassName("DrillDownData").innerText

WScript.Sleep 1000

objExplorer.Quit

0 个答案:

没有答案