这段代码,为什么下载网页时不正常?
我用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
--------------------编程问答-------------------- 用封包协议技术更好,速度能提高几百倍,一般情况下几百上千次也不大会出错 --------------------编程问答-------------------- 谢谢,能说详细点吗?
补充:VB , VBA