我已经问了几次这个问题,但我不觉得我已经实现了我想要的东西。有几个人在这里提供了帮助,但我仍然有使用数据的问题,因为它不是可用的格式。
我希望网站上的链接内容通过VBA
放入工作表该链接位于网页的右上角。
链接
http://bmreports.com/servlet/com.logica.neta.bwp_PanBMDataServlet
到目前为止代码:
Set ie = CreateObject("InternetExplorer.Application")
ie.Navigate "http://bmreports.com/servlet/com.logica.neta.bwp_PanBMUTop"
ie.Visible = True
Do Until Not ie.Busy And ie.readyState = 4
DoEvents
Loop
ie.Document.getelementbyid("param5").Value = "2014-04-16"
ie.Document.getelementbyid("param6").Value = "43"
ie.Document.getelementbyid("go_button").Click
Set objShell = CreateObject("Shell.Application")
IE_count = objShell.Windows.Count
For x = 0 To (IE_count - 1)
On Error Resume Next ' sometimes more web pages are counted than are open
my_url = objShell.Windows(x).Document.Location
my_title = objShell.Windows(x).Document.Title
If my_url Like "http://bmreports.com/servlet/com.logica.neta.bwp_PanBMDataServlet" Then
Set ie = objShell.Windows(x)
Exit For
Else
End If
Next
For Each ele In ie.Document.getElementsByTagName("span")
If ele.innerhtml = "Current data in CSV format" Then
DoEvents
ele.Click
'At this point you need to Save the document manually
' or figure out for yourself how to automate this interaction.
End If
Next
If my_url Like "about:blank" Then
Set ie = objShell.Windows(x)
Else
End If
table_html = ie.Document.getElementsByTagName(("Text"))(2).innerhtml
html_lines = Split(table_html, Chr(10), -1, vbTextCompare)
Worksheets("Sheet1").Activate
Range("A1").Select
For x = 0 To UBound(html_lines)
ActiveCell = html_lines(x)
ActiveCell.Offset(1, 0).Select
Next
答案 0 :(得分:1)
这样做你想要的吗?
Sub Test()
Set ie = CreateObject("InternetExplorer.Application")
ie.Navigate "http://bmreports.com/servlet/com.logica.neta.bwp_PanBMDataServlet"
ie.Visible = True
Do Until Not ie.Busy And ie.readyState = 4
DoEvents
Loop
ie.ExecWB 17, 2 ' select the data
ie.ExecWB 12, 0 ' copy the data
ActiveSheet.PasteSpecial Format:="Text", link:=False, DisplayAsIcon:=False ' paste the data
End Sub