.ApplyStyleHeadingRows = True
.ApplyStyleLastRow = False
.ApplyStyleFirstColumn = True
.ApplyStyleLastColumn = False
.ApplyStyleRowBands = True
.ApplyStyleColumnBands = False
End WithInsert contact data from Access table into Word table:
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset(“tblContacts”)
Do While Not rst.EOF
With appWord.Selection
.TypeText rst![LastName] & “, “ & rst![FirstName]
.MoveRight Unit:=wdCell, Count:=2
End With
rst.MoveNext
LoopDelete the last, blank row:
appWord.Selection.Rows.DeleteSort contact names alphabetically:
doc.Tables(1).Select
appWord.Selection.Sort ExcludeHeader:=False, _
FieldNumber:=”Column 1”, _
SortFieldType:=wdSortFieldAlphanumeric, _
SortOrder:=wdSortOrderAscendingErrorHandlerExit:
Set appWord = Nothing
Exit SubErrorHandler:
If Err = 429 ThenWord is not running; open Word with CreateObject:
Set appWord = CreateObject(“Word.Application”)
Resume Next
Else
MsgBox “Error No: “ & Err.Number _
& “; Description: “ & Err.Description
Resume ErrorHandlerExit
End IfEnd SubCreating Word Documents from Access 2