我用VBA寫了一段代碼,是用來下載單位內部網頁的,我在作業薄的表6中A列加入了企業代碼,然后用VBA依次讀取企業代碼填入查詢框中,然后再網頁框架中有企業資訊,我找到了網頁框架中的網址,直接登陸網址,下載企業資訊,現在問題是我企業代碼一個一個輸入查詢下載正常,但一旦把企業代碼放入A列中讀取自動填入框架中,自動查詢網頁也正常,但下載只能下載第一個回圈,再次回圈時就不能下載了。我寫的的代碼如下:
Sub 企業資訊()
On Error Resume Next
Dim mytrade As String, waitTime As String, ie As Object, y As Integer
Set ie = CreateObject("InternetExplorer.Application")
intnum = Application.WorksheetFunction.CountA([A:A])
For y = 1 To intnum - 1
Application.ScreenUpdating = True
mytrade = Sheet6.Cells(y + 1, 1).Value
'mytrade = "4404110005"
With CreateObject("InternetExplorer.Application")
.Visible = True
.Navigate "http://10.55.7.80/entmgr/App_Web/ent_base.aspx"
Do Until .ReadyState = 4
DoEvents
Loop
.Document.All("DropDownList1").Value = "trade_co"
.Document.All("ZLTextBox7").Value = mytrade
.Document.getElementById("Button2").Click
waitTime = TimeSerial(Hour(Now()), Minute(Now()), Second(Now()) + 1)
Application.Wait waitTime
.Document.getElementById("GridView1_ctl02_btnSelect").Click
waitTime = TimeSerial(Hour(Now()), Minute(Now()), Second(Now()) + 1)
Application.Wait waitTime
.Navigate "http://10.55.7.80/entmgr/App_Web/ent_baseinfo.aspx"
waitTime = TimeSerial(Hour(Now()), Minute(Now()), Second(Now()) + 1)
Application.Wait waitTime
n = Sheet1.Range("A65536").End(xlUp).Row + 1
Set r = .Document.All.tags("table")(0).Rows
For i = 0 To r.Length - 1
For j = 1 To r(i).Cells.Length - 1 Step 2
k = k + 1
Sheet1.Cells(n, k) = r(i).Cells(j).innerText
Next j
Next i
Set r = Nothing
.Quit
End With
Next y
End Sub
uj5u.com熱心網友回復:
用封包協議技術更好,速度能提高幾百倍,一般情況下幾百上千次也不大會出錯uj5u.com熱心網友回復:
謝謝,能說詳細點嗎?轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/150692.html
標籤:VBA
下一篇:vb+sql移植方法
