|
本帖最后由 hahada 于 2014-4-23 16:45 编辑
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Option Explicit
Sub a()
Dim ie1 As Object, t As Single
Dim dWinFolder As New ShellWindows, oj
Set ie1 = CreateObject("InternetExplorer.Application")
With ie1
.Visible = True
.Navigate "http://219.132.79.206/login.aspx" '网址
Do Until .ReadyState = 4 And .Busy = False
DoEvents
Loop
.Document.all("_ctl0_ContentPlaceHolder1_txtUserID").Value = "pnco"
.Document.all("_ctl0_ContentPlaceHolder1_txtPWD").Value = "1234"
.Document.all("_ctl0_ContentPlaceHolder1_btnLogin").Click
Do Until .ReadyState = 4 And .Busy = False
DoEvents
Loop
.Navigate "http://219.132.79.206/main.aspx?NAVID=EveryDynamicContainerQuery&q=0"
Do Until .ReadyState = 4 And .Busy = False
DoEvents
Loop
With .Document
.all("_ctl0_ContentPlaceHolder1_CB_CHL_1338").Click
On Error Resume Next
Do Until ie1.ReadyState = 4 And ie1.Busy = False And .all("_ctl0_ContentPlaceHolder1_CHL_1338_5").Checked = False
DoEvents
Loop
On Error GoTo 0
.all("_ctl0_ContentPlaceHolder1_CHL_1338_6").Checked = True
.all("_ctl0_ContentPlaceHolder1_CHL_1338_7").Checked = True
.all("_ctl0_ContentPlaceHolder1_CHL_1338_8").Checked = True
.all("_ctl0:ContentPlaceHolder1:DATE_1344Input").Value = "2012-03-01 08:00"
.all("_ctl0_ContentPlaceHolder1_btnOK").Click
t = Timer
Do Until ie1.ReadyState = 4 And ie1.Busy = False And Timer > t + 1
DoEvents
Loop
Do
For Each oj In dWinFolder
If InStr(oj.LocationName, "查询结果") > 0 Then Exit Do
Next
DoEvents
Loop
.parentwindow.eval "javascript:window.opener=null;window.open('','_self');window.close();"
Set ie1 = oj
Do Until ie1.ReadyState = 4 And ie1.Busy = False
DoEvents
Loop
End With
End With
ie1.Document.all("btnExcel").Click
Do Until FindWindow(vbNullString, "文件下载") > 0
DoEvents
Loop
Sleep 600
SendKeys "%S"
Do Until FindWindow(vbNullString, "另存为") > 0
DoEvents
Loop
SendKeys "c:\myfile.xls", True
SendKeys "%S"
Set ie1 = Nothing
End Sub
|
|