自动填表中提交后转到下一页继续自动填表的问题
有1个网站的注册,自动填表提交后会转到下一页,要继续填表,我连续用了2个if webbrowser1.locationURL = "XXXX" then 的语句,但会有“错误91,对象变量或with模块未设置”提示,就类似于:Dim strURL
Private Sub Form_Load()
WebBrowser1.Navigate "www.9991.com"
End Sub
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
If WebBrowser1.LocationURL = "http://www.9991.com/" Then
WebBrowser1.Document.getElementById("uName2").Value = "cnsldk@21cn.com"
End If
If WebBrowser1.LocationURL = "http://www.sina.com.cn/" Then
WebBrowser1.Document.getElementById("username").Value = "易做图sdjfsl"
End If
End Sub
Private Sub WebBrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean)
Cancel = True
WebBrowser1.Navigate strURL
End Sub
Private Sub WebBrowser1_StatusTextChange(ByVal Text As String)
strURL = Text
End Sub
请问怎样才能搞到啊?
窗体中有一个webbrowser1控件,form load时webbrowser1自动打开网站www.9991.com并自动填表(不提交),点www.9991.com上的新浪链接,
在webbrowser1打开http://www.sina.com.cn(不在外部浏览器打开新窗口)并同时自动填表,我的代码的问题在于
If WebBrowser1.LocationURL = "http://www.sina.com.cn/" Then
WebBrowser1.Document.getElementById("username").Value = "易做图sdjfsl"
End If
如果没有上面的代码,则没有出错提示,但实现不了点击新浪后能自动填表的功能,如果有上面代码,会出现“错误91,对象变量或with模块未设置”提示。请问怎样才能搞到啊(最好有源码)?
--------------------编程问答--------------------
Dim strURL As String '<- 变量命名和类型要一致
Private Sub Form_Load()
WebBrowser1.Navigate "www.9991.com"
End Sub
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
strURL = URL '<- 这个才是有效地址
If strURL = "http://www.9991.com/" Then '<-
WebBrowser1.Document.getElementById("uName2").Value = "cnsldk@21cn.com"
End If
If strURL = "http://www.sina.com.cn/" Then '<-
WebBrowser1.Document.getElementById("username").Value = "易做图sdjfsl"
End If
End Sub
Private Sub WebBrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean)
Cancel = True
WebBrowser1.Navigate strURL
End Sub
'状态只是类似 "正在下载图片 ..."、"完成" 等提示文字,和 URL 有什么关系!!!
'Private Sub WebBrowser1_StatusTextChange(ByVal Text As String)
'strURL = Text
'End Sub
--------------------编程问答--------------------
不行啊 --------------------编程问答--------------------
我试了下,两个网页都不能填表,而且从9991点击新浪后,新浪网过几秒会自动关闭,不知为什么?如果有其它方法,可以指导下吗?谢谢! --------------------编程问答--------------------
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
Debug.Print "DocumentComplete(, " & URL & ")"
...
End Sub
Private Sub WebBrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean)
Debug.Print "NewWindow2()"
...
End Sub
--------------------编程问答--------------------
补充:VB , 基础类