Option Explicit
Sub FillTable()
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim strConn As String
Dim Doca As Document
Dim para As Paragraph
Dim rng As Range
Dim strDateText As String
Dim tbl As Table
Dim rw As Word.Row
Set Doca = ActiveDocument
Set cn = New ADODB.Connection
cn.Provider = "Microsoft.ACE.OLEDB.12.0"
cn.Open "P:\KO Quality\KO Reporting\KO Weekly Reporting Data\Current Reporting Database\KO Quality Master 2008 Linked.accdb"
Set rs = New ADODB.Recordset
rs.Open "L2CAR_KOJ_Wood_Table", cn, adOpenDynamic, adLockOptimistic, adCmdTable
Set tbl = Doca.Tables.Add(Doca.Bookmarks("\EndOfDoc").Range, 1, 5)
tbl.Cell(1, 1).Range.Text = "Activity Type"
tbl.Cell(1, 2).Range.Text = "Number"
tbl.Cell(1, 3).Range.Text = "Start Date"
tbl.Cell(1, 4).Range.Text = "Status"
tbl.Cell(1, 5).Range.Text = "Defect Code"
Do Until rs.EOF
Set rw = tbl.Rows.Add
rw.Cells(1).Range.Text = rs.Fields("Activity Type").Value
rw.Cells(2).Range.Text = rs.Fields("Number").Value
rw.Cells(3).Range.Text = rs.Fields("Start Date").Value
rw.Cells(4).Range.Text = rs.Fields("Status").Value
rw.Cells(5).Range.Text = rs.Fields("Defect Code").Value
rs.MoveNext
Loop
rs.Close
cn.Close
End Sub
PowerPoint-Error.jpg
ASKER
Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.
TRUSTED BY
ASKER
Thank you. (That was your code by the way.)
I also need some clean up on the PowerPoint Object Model vs the Word Object Model, so I may need to ask an additional follow up question or two.