工程已经引用了 Microsoft HTML Object LibraryPrivate Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
    Dim HTML1 As String, HTML2 As String
    Dim Webdoc As HTMLDocument
    Set Webdoc = WebBrowser1.Document
    
    If Webdoc.Title = "MyWebSite" Then 
     HTML1 = Webdoc.getElementById("HTML1").Value
     HTML2 = Webdoc.getElementById("HTML2").Value'取得网页文本框里的字符串
    End If
    
End Sub用Err.Description 和 Err.Number 得出错误为:错误信息: 未设置对象变量或 With block变量   错误代码:91

解决方案 »

  1.   

    把("HTML1").Value 中的引号去掉 改为 (HTML1).Value 试试
      

  2.   

    Dim Webdoc As HTMLDocument 要改为
    Dim Webdoc As new HTMLDocument 
      

  3.   


    可以了啊····谢谢··········Dim Webdoc As HTMLDocument 和 Dim Webdoc As new HTMLDocument的区别在哪里??需要使用 Set Nothing 吗?
      

  4.   

    Set Webdoc = new WebBrowser1.Document 
      

  5.   

    Dim Webdoc As NEW HTMLDocument 
    LZ,DOM是个对象
      

  6.   

    DOCUMENT只是DOM对象下面的一个支线,建议LZ学习一下DOM模型