打开新链接后自动填表的问题窗体中有一个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 = "cndsdjfsl"
End If如果没有上面的代码,则没有出错提示,但实现不了点击新浪后能自动填表的功能,如果有上面代码,会出现“错误91,对象变量或with模块未设置”提示。请问如何修改才能达到我的要求(我这里用的是网址判断)?全部代码如下:
Dim strURL
Private Sub Form_Load()
WebBrowser1.Navigate "www.9991.com"
End SubPrivate Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
If WebBrowser1.LocationURL = "http://www.9991.com/" Then
WebBrowser1.Document.getElementById("uName2").Value = "[email protected]"
End IfIf WebBrowser1 StatusTextChange then
      if  WebBrowser1.LocationURL = "http://www.sina.com.cn/" Then
WebBrowser1.Document.getElementById("username").Value = "cndsdjfsl"
End If
end if
End SubPrivate Sub WebBrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean)
Cancel = True
WebBrowser1.Navigate strURL
    End SubPrivate Sub WebBrowser1_StatusTextChange(ByVal Text As String)strURL = Text
End Sub