Private Sub Form_Load()
Dim ie        As InternetExplorer
Dim sWind     As ShellWindows
Set ie = CreateObject("internetexplorer.application")
ie.Visible = True
ie.navigate ("http://www.baidu.com/")
End SubPrivate Sub Timer1_Timer()
On Error Resume Next
Set sWind = New ShellWindows
For Each ie In sWind
    If ie.Busy = False Then
        If LCase(Mid(ie.locationURL, 1, 4)) <> "file" Then
            If ie.locationURL = "http://www.baidu.com/" Then
              Print ie.document.documentElement.outerHTML
               'ie.document.getElementById("TextBox1").Value = "chenlin3"
             '  ie.document.getElementById("TextBox2").Value = "888888"
            '   ie.document.getElementById("Button1").Click
             End If
          End If
     end ifNext
End Sub这个时候怎么得到IE的源码?pDisp.document.documentElement.outerHTML在WEBBROWSER中是可以的,到这儿却不行了

解决方案 »

  1.   

    Dim ie        As InternetExplorer
    Dim sWind     As ShellWindowsie,sWind 至少应定义成窗体级全局变量
      

  2.   

    ie,sWind 没有定义成窗体级全局变量那些赋值和点击也是能用的,那么取其源码也应该没有问题的呀
      

  3.   

    把万恶的On Error Resume Next去掉,看看有什么效果?
      

  4.   

    Option ExplicitPrivate Sub Form_Load()
    Dim ie        As InternetExplorer
    Dim sWind     As ShellWindows
    Set ie = CreateObject("internetexplorer.application")
    ie.Visible = True
    ie.navigate ("http://www.baidu.com/")
    End SubPrivate Sub Timer1_Timer()
    On Error Resume Next
    Dim sWind, ie
    Set sWind = New ShellWindows
    For Each ie In sWind
        If ie.Busy = False Then
            If LCase(Mid(ie.locationURL, 1, 4)) <> "file" Then
                If ie.locationURL = "http://www.baidu.com/" Then
                  Print ie.document.documentElement.outerHTML
                  MsgBox ie.document.documentElement.outerHTML
                   'ie.document.getElementById("TextBox1").Value = "chenlin3"
                 '  ie.document.getElementById("TextBox2").Value = "888888"
                '   ie.document.getElementById("Button1").Click
                 End If
              End If
         End IfNext
    End Sub有用的
      

  5.   

                Me.Cls
                  Print Now & "--" & ie.document.documentElement.outerHTMLOption ExplicitPrivate Sub Form_Load()
    Dim ie        As InternetExplorer
    Dim sWind     As ShellWindows
    Set ie = CreateObject("internetexplorer.application")
    ie.Visible = True
    ie.navigate ("http://www.baidu.com/")
    End SubPrivate Sub Timer1_Timer()
    On Error Resume Next
    Dim sWind, ie
    Set sWind = New ShellWindows
    For Each ie In sWind
        If ie.Busy = False Then
            If LCase(Mid(ie.locationURL, 1, 4)) <> "file" Then
                If ie.locationURL = "http://www.baidu.com/" Then
                Me.Cls
                  Print Now & "--" & ie.document.documentElement.outerHTML
                  'MsgBox ie.document.documentElement.outerHTML
                   'ie.document.getElementById("TextBox1").Value = "chenlin3"
                 '  ie.document.getElementById("TextBox2").Value = "888888"
                '   ie.document.getElementById("Button1").Click
                 End If
              End If
         End IfNext
    End Sub
      

  6.   

    因为一开始打开软件的时候网页还没下载完成,所以上面显示的内空僦是空白。
    再说PRINT是从上往下打印,一个窗体就这么小,一个网页内容要几个窗体这么高才能显示下来,所以只能每次CLS清空一下