有个操作IE的语句Dim IE
Set IE = CreateObject("Internetexplorer.application") '建立 连接 浏览器
IE.Visible = True ' 浏览器 是否可见,可以为数据 1 = true , 0 = false
IE.Navigate "http://148.36.20.220:86/" ' 导航 制定的 网址'IE.gohome '这个是打开主页
Do While IE.readystate <> 4 ' 这个是 判断 浏览器打开的网页是否装载 完全
Loop
If IE.LocationURL = "http://148.36.20.220:86/" Then
IE.Document.Forms(0).elements("TextBox2").Value = "888888" ' 设置表单值
IE.Document.Forms(0).elements("TextBox1").Value = "chenlin3" '同上
IE.Document.Forms(0).elements("Button1").Click '模拟点击表单
ElseIf IE.LocationURL = "http://148.36.20.220:86/qd.aspx" Then
MsgBox "ddddddddddddddddddddddddddddddd"End IfIE.quit ' 退出
'Set IE = Nothing '销毁 ie对象 就是释放内存 是个好习惯有个问题想让大家帮解决一下,就是到IE.LocationURL = "http://148.36.20.220:86/qd.aspx"后他怎么不运行了?MSGBOX出不来提示啊!,
Set IE = CreateObject("Internetexplorer.application") '建立 连接 浏览器
IE.Visible = True ' 浏览器 是否可见,可以为数据 1 = true , 0 = false
IE.Navigate "http://148.36.20.220:86/" ' 导航 制定的 网址'IE.gohome '这个是打开主页
Do While IE.readystate <> 4 ' 这个是 判断 浏览器打开的网页是否装载 完全
Loop
If IE.LocationURL = "http://148.36.20.220:86/" Then
IE.Document.Forms(0).elements("TextBox2").Value = "888888" ' 设置表单值
IE.Document.Forms(0).elements("TextBox1").Value = "chenlin3" '同上
IE.Document.Forms(0).elements("Button1").Click '模拟点击表单
ElseIf IE.LocationURL = "http://148.36.20.220:86/qd.aspx" Then
MsgBox "ddddddddddddddddddddddddddddddd"End IfIE.quit ' 退出
'Set IE = Nothing '销毁 ie对象 就是释放内存 是个好习惯有个问题想让大家帮解决一下,就是到IE.LocationURL = "http://148.36.20.220:86/qd.aspx"后他怎么不运行了?MSGBOX出不来提示啊!,
Private Sub Form_Load()
Dim IE
Dim i As Integer
Set IE = CreateObject("Internetexplorer.application") '建立 连接 浏览器
IE.Visible = True ' 浏览器 是否可见,可以为数据 1 = true , 0 = false
IE.Navigate "http://148.36.20.220:86/" ' 导航 制定的 网址
Dim s
s = Array(chenlin3, lujun3, wangping19)
i = 0
Dim wy
End SubPrivate Sub Timer1_Timer()
If i = 4 Then
IE.quit
Set IE = Nothing
Unload Me
Else:
Do While IE.readystate <> 4 ' 这个是 判断 浏览器打开的网页是否装载 完全
Loop
IE.Document.Forms(0).elements("TextBox2").Value = "888888" ' 设置表单值
IE.Document.Forms(0).elements("TextBox1").Value = s(i) '同上
i = i + 1
IE.Document.Forms(0).elements("Button1").Click
Timer2.Enabled = True
Timer1.Enabled = FalseEnd IfEnd SubPrivate Sub Timer2_Timer()
Do While IE.readystate <> 4 ' 这个是 判断 浏览器打开的网页是否装载 完全
Loop
Debug.Print IE.Document.documentElement.outerHTML
End Sub
两个毛病:1是IE.Document.Forms(0).elements("TextBox1").Value = s(i) 它提示子程序或函数未定义,郁闷;;2是TIMER2中Do While IE.readystate <> 4 这一句却又出问题了,他提示实时错误424,要求对象!无语中
放在所有代码的最上面的"通用"里声明,因为其使用跨越了sub
新的问题发新的帖子,否则别人未必注意到
Do While IE.readystate <> 4 ' 这个是 判断 浏览器打开的网页是否装载 完全
Loop
If IE.LocationURL = "http://148.36.20.220:86/" Then
IE.Document.Forms(0).elements("TextBox2").Value = "888888" ' 设置表单值
IE.Document.Forms(0).elements("TextBox1").Value = "chenlin3" '同上
IE.Document.Forms(0).elements("Button1").Click '模拟点击表单
ElseIf IE.LocationURL = "http://148.36.20.220:86/qd.aspx" Then
MsgBox "ddddddddddddddddddddddddddddddd"
End If
他在第一步时就是打开网页http://148.36.20.220:86/后,会自动填表单,但是提交表单后产生的第二个页面就没有任何处理动作了,也就是MSGBOX不出来,在IF前加不加doevents都是一样,我换成TIMER后,发现TIMER1却不自动填写表单,但是其后面的Timer2.Enabled = True
Timer1.Enabled = False却起了作用了,Timer2中的Debug.Print IE.Document.documentElement.outerHTML发挥了作用,他打印出了第一个网页(http://148.36.20.220:86/)的源码,由于没有及时关闭TIMER2,这时间稍长了后,又会提示Do While IE.readystate <> 4 实时错误424,要求对象!
还在晕呼中
Do While IE.readystate <> 4 ' 这个是 判断 浏览器打开的网页是否装载 完全
If IE.LocationURL = "http://148.36.20.220:86/" Then
IE.Document.Forms(0).elements("TextBox2").Value = "888888" ' 设置表单值
IE.Document.Forms(0).elements("TextBox1").Value = "chenlin3" '同上
IE.Document.Forms(0).elements("Button1").Click '模拟点击表单
ElseIf IE.LocationURL = "http://148.36.20.220:86/qd.aspx" Then
MsgBox "ddddddddddddddddddddddddddddddd"
End If
Loop
这回却又提示IE.Document.Forms(0).elements("TextBox2").Value = "888888" 这句要求对象或WITH对象,。
Dim IE
Set IE = CreateObject("Internetexplorer.application") '建立 连接 浏览器
IE.Visible = True ' 浏览器 是否可见,可以为数据 1 = true , 0 = false
IE.Navigate "http://148.36.20.220:86/" ' 导航 制定的 网址'IE.gohome '这个是打开主页
Do While IE.readystate <> 4 ' 这个是 判断 浏览器打开的网页是否装载 完全
Loop
If IE.LocationURL = "http://148.36.20.220:86/" Then
IE.Document.Forms(0).elements("TextBox2").Value = "888888" ' 设置表单值
IE.Document.Forms(0).elements("TextBox1").Value = "chenlin3" '同上
IE.Document.Forms(0).elements("Button1").Click '模拟点击表单
ElseIf IE.LocationURL = "http://148.36.20.220:86/qd.aspx" Then
MsgBox "ddddddddddddddddddddddddddddddd"
End If
IE.quit ' 退出
Set IE = Nothing '销毁 ie对象 就是释放内存 是个好习惯这样就能自动填http://148.36.20.220:86/的表单,但是只会操作第一个网页,不会进行第二个页面的处理