Ошибка object reqired при очистке БД |
Private Sub cmdImport_Click() Dim appWord As Word.Application, doc As Word.Document Dim dbs As DAO.Database, rst As DAO.Recordset, strDoc As String Set appWord = CreateObject("Word.Application") 'establish an instance of word strDoc = CurrentProject.Path & "\People.docx" 'set string to document path and file Set doc = appWord.Documents.Open(strDoc) 'establish the document Set dbs = CurrentDb 'establish the database to use (this is our current Database) Set rst = dbs.OpenRecordset("tblPeople") 'establish the recordset With doc.Tables(1) 'target table 1 in People.docx For i = 2 To .Rows.Count 'cycle through rows in Tables(1) [we skip the first row because the table has headers] With rst .AddNew 'creating a new record ![FName] = doc.Tables(1).Cell(i, 1).Range.Text ![LName] = doc.Tables(1).Cell(i, 2).Range.Text ![SSN] = doc.Tables(1).Cell(i, 3).Range.Text ![PhoneNumber] = doc.Tables(1).Cell(i, 5).Range.Text ![Gender] = doc.Tables(1).Cell(i, 6).Range.Text .Update 'update the whole record End With Next 'go to next row in Tables(1) End With rst.Close: Set rst = Nothing 'close and clear recordset db.Close: Set rst = Nothing 'close and clear database doc.Close: Set doc = Nothing 'close and clear document appWord.Quit: Set appWord = Nothing 'close and clear MS Word End Sub
Private Sub Кнопка0_Click() Dim appWord As Word.Application, doc As Word.Document Dim dbs As DAO.Database, rst As DAO.Recordset, strDoc As String Set appWord = CreateObject("Word.Application") 'establish an instance of word strDoc = "C:\Documents and Settings\Admin\Рабочий стол\tblTest.docx" 'set string to document path and file Set doc = appWord.Documents.Open(strDoc) 'establish the document Set dbs = CurrentDb 'establish the database to use (this is our current Database) Set rst = dbs.OpenRecordset("tblTest") 'establish the recordset With doc.Tables(1) 'target table 1 in People.docx For i = 2 To .Rows.Count 'cycle through rows in Tables(1) [we skip the first row because the table has headers] With rst .AddNew 'creating a new record ![ob] = doc.Tables(1).Cell(i, 1).Range.Text ![smr] = doc.Tables(1).Cell(i, 2).Range.Text ![emm] = doc.Tables(1).Cell(i, 3).Range.Text ![mat] = doc.Tables(1).Cell(i, 4).Range.Text .Update 'update the whole record End With Next 'go to next row in Tables(1) End With rst.Close: Set rst = Nothing 'close and clear recordset db.Close: Set rst = Nothing 'close and clear database doc.Close: Set doc = Nothing 'close and clear document appWord.Quit: Set appWord = Nothing 'close and clear MS Word End Sub
db.Close: Set rst = Nothing 'close and clear database
http://www.sql.ru/forum/1258017/oshibka-object-reqired-pri-ochistke-bd
Комментировать | « Пред. запись — К дневнику — След. запись » | Страницы: [1] [Новые] |