I am trying to add a table to a word document from access and keep getting the dreaded "Object Required" at wordapp.ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=1, NumColumns:=5
OK so I may be the only one that dreads it.
Dim dbs As Database
Dim wordapp As Object
Dim rst As Recordset
Dim strDocPath As String
strDocPath = "F:\Secy-SD\ServiceList\MonthlyReport.Doc"
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("QuarterlyClientInfoQuery"
rst.MoveLast
rst.MoveFirst
Set wordapp = CreateObject("Word.Application"
With wordapp
.Visible = True
.Documents.Open (strDocPath)
End With
wordapp.ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=1, NumColumns:=5
With Selection.Tables(1)
If .Style <> "Table Grid" Then
.Style = "Table Grid"
End If
.ApplyStyleHeadingRows = True
.ApplyStyleLastRow = False
.ApplyStyleFirstColumn = True
.ApplyStyleLastColumn = False
End With
'Put Column Titles in First Row
'Add New Table
'Do While rst.EOF = False
'Concantenate Data
'Insert Data into Cell
'Move To Next Cell
'Move To Next Row
OK so I may be the only one that dreads it.
Dim dbs As Database
Dim wordapp As Object
Dim rst As Recordset
Dim strDocPath As String
strDocPath = "F:\Secy-SD\ServiceList\MonthlyReport.Doc"
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("QuarterlyClientInfoQuery"
rst.MoveLast
rst.MoveFirst
Set wordapp = CreateObject("Word.Application"
With wordapp
.Visible = True
.Documents.Open (strDocPath)
End With
wordapp.ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=1, NumColumns:=5
With Selection.Tables(1)
If .Style <> "Table Grid" Then
.Style = "Table Grid"
End If
.ApplyStyleHeadingRows = True
.ApplyStyleLastRow = False
.ApplyStyleFirstColumn = True
.ApplyStyleLastColumn = False
End With
'Put Column Titles in First Row
'Add New Table
'Do While rst.EOF = False
'Concantenate Data
'Insert Data into Cell
'Move To Next Cell
'Move To Next Row