请问:怎么修正:实时错误91,“对象变量或with变量未设置”(黄色标向:Set lrow = table.rows(0))
这是获取webbrowser控件网页的表格内容导入数据表中,运行出现:实时错误91,“对象变量或with变量未设置”Private Sub Command1_Click()
WebBrowser1.navigate "http://www.
End Sub
Private Sub Form_Load()
WebBrowser1.Stop
End Sub
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
Dim doc As MSHTML.HTMLDocument
Set doc = WebBrowser1.document
Dim table As MSHTML.HTMLTable
Dim lrow As MSHTML.HTMLTableRow
Dim cel As MSHTML.HTMLTableCell
Set table = doc.getElementById("REPORTID_tab1")
Dim Conn As ADODB.Connection
Dim FLD() As String
Set Conn = CreateObject("ADODB.Connection")
Conn.Open "provider=microsoft.jet.oledb.4.0;data source=d:\DB1.MDB"
Set lrow = table.rows(0)
ReDim FLD(0 To lrow.cells.length) As String
Dim i As Integer
Dim tbname As String
Dim sql As String
tbname = InputBox("表1", "table1")
For i = 0 To lrow.cells.length - 1
FLD(i) = Replace(Replace(Replace(lrow.cells(i).innerText, "/", ""), "(", ""), ")", "")
sql = sql & FLD(i) & " varchar(255),"
Next i
sql = Left(sql, Len(sql) - 1)
Conn.Execute "create table " & tbname & " (" & sql & ")"
Dim j As Integer
sql = ""
For i = 0 To lrow.cells.length - 1
sql = sql & FLD(i) & ","
Next i
sql = Left(sql, Len(sql) - 1)
Dim vlist As String
For i = 1 To table.rows.length - 1
vlist = ""
Set lrow = table.rows(i)
For j = 0 To lrow.cells.length - 1
vlist = vlist & "'" & lrow.cells(j).innerText & "',"
Next j
vlist = Left(vlist, Len(vlist) - 1)
Conn.Execute "insert into " & tbname & " (" & sql & ") values (" & vlist & ")"
Next i
Conn.Close
Set Conn = Nothing
End Sub