|
楼主 |
发表于 2011-4-1 20:57
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
回复smileoa短信,武汉的也做好了
代码如下,EXCEL见附件,你试看看行不?- Option Explicit
- Sub Test()
- Dim I As Integer, Getpage As String, Tmp1() As String, Tmp2() As String, xmlhttp As Object, N As Integer, Fpdm As String, Fphm As String
-
- On Error Resume Next
- N = [a65536].End(xlUp).Row
- For I = 1 To N - 1
- Cells(2, 3).Value = "正在查询第" & I & "张"
- Fpdm = Trim(Cells(I + 1, 1).Value)
- Fphm = Trim(Cells(I + 1, 2).Value)
- Set xmlhttp = CreateObject("Microsoft.XMLHTTP")
- With xmlhttp
- .Open "get", "http://219.140.196.6/cms/wh05/index.jsp?fpdm=" & Fpdm & "&fphm=" & Fphm & "&action=queryed", False
- .send
- Getpage = Replace(.responsetext, vbCrLf, "")
- End With
- If InStr(Getpage, "<b><font color=""blue"">") > 0 Then
- Cells(I + 1, 4).Value = Split(Split(Getpage, "<b><font color=""blue"">")(1), "</font>")(0)
- Tmp1() = Split(Getpage, "<td align=""left"" width=""80%""><b>")
- Cells(I + 1, 5).Value = Split(Tmp1(1), "</b>")(0)
- Cells(I + 1, 6).Value = Split(Tmp1(2), "</b>")(0)
- Cells(I + 1, 7).Value = Split(Tmp1(3), "</b>")(0)
- Cells(I + 1, 8).Value = Split(Tmp1(4), "</b>")(0)
- ElseIf InStr(Getpage, "<b><font color=""red"">") > 0 Then
- Cells(I + 1, 4).Value = Split(Split(Getpage, "<b><font color=""red"">")(1), "</font>")(0)
- Tmp1() = Split(Getpage, "<td align=""left"" width=""80%""><b>")
- Cells(I + 1, 5).Value = Split(Tmp1(1), "</b>")(0)
- Cells(I + 1, 6).Value = Split(Tmp1(2), "</b>")(0)
- Tmp2() = Split(Getpage, "<td colspan=""3"" align=""left"">")
- Cells(I + 1, 7).Value = Split(Tmp2(1), "</td>")(0)
- Cells(I + 1, 8).Value = Split(Tmp2(2), "</td>")(0)
- Else
- Cells(I + 1, 4).Value = "未知错误!"
- End If
- Erase Tmp1
- Erase Tmp2
- Getpage = ""
- Set xmlhttp = Nothing
- Next
- Cells(2, 3).Value = "查询状态栏"
- MsgBox "查询完毕!"
- End Sub
复制代码 |
|