On 5/31/2010 2:57 PM, ArmySoldier72 wrote:
Did you turn on the DAO reference?
Yes, I did it.
open the VBA editor.
click tools - References and select Microsoft ActiveX Data Objects
i also select Microsoft DAO
hope that helps
The code(modified a bit) is below:
Sub ReturnTableText()
Dim oTable As Table
Dim oRow As Row
Dim oRng As Range
Dim sText As String
Dim count As Integer
Dim dbMyDB As DAO.Database
Dim myRecordSet As DAO.Recordset
Set dbMyDB = OpenDatabase("C:\mydatabase.accdb") ' this line throws an '
error Run Time Error 429 ActiveX component can't create object or
' return reference to this object
Set myRecordSet = dbMyDB.OpenRecordset("Table1", dbOpenDynaset)
sText = ""
count = 0
For Each oTable In ActiveDocument.Tables
For Each oRow In oTable.Rows
If oRow.Cells.count 1 Then
Set oRng = oRow.Cells(oRow.Cells.count).Range
oRng.End = oRng.End - 1
myRecordSet.Fields(count).Value = oRng.Text & Chr(44)
MsgBox myRecordSet.Fields(count).Value
count = count + 1
End If
Next oRow
Next oTable
myRecordSet.Close
dbMyDB.Close
End Sub
I checked the documentation at
http://msdn.microsoft.com/en-us/libr...8VS.60%29.aspx
but could not solve it.
Any advice would be appreciated.
Thanks for your reply.