Excel精英培训网

 找回密码
 注册
数据透视表40+个常用小技巧,让你一次学会!
查看: 3388|回复: 2

[已解决]解释代码?

[复制链接]
发表于 2014-4-23 16:16 | 显示全部楼层 |阅读模式
本帖最后由 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
最佳答案
2014-4-23 16:23
大部分是操作IE对象的。
HTML DOM的资料可在这里查。
http://www.w3school.com.cn/htmldom/index.asp

另外就是API的。
刚开始入门,别不用急着弄清所有的,知道代码干什么就成了。
发表于 2014-4-23 16:23 | 显示全部楼层    本楼为最佳答案   
大部分是操作IE对象的。
HTML DOM的资料可在这里查。
http://www.w3school.com.cn/htmldom/index.asp

另外就是API的。
刚开始入门,别不用急着弄清所有的,知道代码干什么就成了。
回复

使用道具 举报

发表于 2014-4-23 20:58 | 显示全部楼层
hwc2ycy 发表于 2014-4-23 16:23
大部分是操作IE对象的。
HTML DOM的资料可在这里查。
http://www.w3school.com.cn/htmldom/index.asp

厉害的网站。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|Excel精英培训 ( 豫ICP备11015029号 )

GMT+8, 2024-4-20 04:49 , Processed in 0.316075 second(s), 9 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表