Access - Write to Word Table

R

robertsclark

Hi
For a lot of the access reports that I generate, I have to
integrate with Word documents. Up to now I have achieved
this by opening a new document based ono a template and
then doing searc/replace for bookmarks within the
template. eg:

If Dir$(sDir, vbDirectory) = "" Then MkDir sDir

Set oApp = CreateObject("word.application")

oApp.Visible = True
If Dir(sFilename) = "" Then
NewWP = 1
Set oApp = CreateObject("word.basic")
With oApp
.filenew template:=sTemplateName
' Find and replace bookmarks

.editbookmark Name:="zwpnoz", Goto:=True
.insert (Trim$(Me.WPNo))

.editbookmark Name:="zwptitlez", Goto:=True
.insert (Me.WPTitle)

.editbookmark Name:="zprojtitlez", Goto:=True
.insert (Forms![sys master form]![Text182])

.editbookmark Name:="zwpmanagerz", Goto:=True
If IsNull(Me.WPManager) Then
.insert ("Unspecified")
Else
.insert (Me.WPManager)
End If
.filesaveas Name:=sFilename
End With
Else
oApp.Documents.Open sFilename
End If




I now have a report where some of the data will come from subrecords
Rather than play with bookmarks, how can I extend my code to
automatically update the tables in my word document, adding extra row
if required?

The table has five columns, with column 1 being a merged cell with
description of the table. Row 1 contins column headings, and the dat
is in columns 2 - 5.

My VB skills are limited, so I need explicit instructions!

Many thanks!

Rober
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top