-2
我已經創建了一個宏,它允許我與網站進行交互並識別源中的某個按鈕,並使用它來將數據導出到Excel文件。下面是我的宏...我在下面找到的問題是在評論中。請讓我知道是否需要進一步的規範。Excel VBA For Each
Sub Scrape1()
Dim Browser As InternetExplorer
Dim Document As HTMLDocument
Dim Elements As IHTMLElementCollection
Dim Element As IHTMLElement
Dim excelElement As IHTMLElement
Dim objElement As Object
Set Browser = New InternetExplorer
Browser.Visible = True
Browser.navigate "http://www.site.com"
Do While Browser.Busy And Not Browser.readyState = READYSTATE_COMPLETE
DoEvents
Loop
Set Document = Browser.Document
Set Elements = Document.getElementById("ctl31_ctl06_ctl04_ctl00_Menu").
getElementsByTagName("a")
For Each Element In Elements
'The object I'm looking to use has an InnerText of "Excel"
'set objElement as the Element with the InnerText of "Excel" so that I can say
objElement.Click
Next Element
Set Document = Nothing
Set Browser = Nothing
End Sub
嗯,這是真棒......問一個問題,得到一個downvote。謝謝匿名。 – Dakota
我不確定爲什麼downvote,但爲什麼不只是說出你在問題中需要什麼,或者至少在你的評論中清楚。評論看起來像是被切斷了,並沒有說明你想做什麼。 –
[[此](http://msdn.microsoft.com/en-us/library/office/aa219845%28v=office.11%29.aspx)是否提供您需要的內容? – Jaycal