Word and Acess

W

Wolfguar

Hello,

I have an access table that I would like to populate the record of the
fields on a Word document, lets say that on the Access table I have contains
X, Y and Z records (which are the same names a the word document and could be
repeaded more that 3 times sometimes) and have several records with 3 fields
for each document that would like to populate and print out (with out opening
the word doc) ,can it be done with some programming and does any one have an
idea that can share it with me?

as an example(will separate the fields with commas) :
Access table
X, 1, 2, 3
X, 1, 3, 4
Y, 3, 4, 6
Y, 7, 2, 1
Y, 6, 3, 7
Z, 4, 5, 7

Word Docs
X.Doc
Y.Doc
Z.Doc

So I need to print out
2 times the X.Doc with each record
3 times the Y.Doc with each record
1 time the Z.Doc with the records

Regards,
 
P

Perry

In this setting, it would be my advise to handle document creation in
Access.
Based on the records retrieved from the table and the mechanism to identify
the
records to Word templates is in place, something like below code do the job
Just by means of example...

Dim cn as ADODB.connection
Dim rs as new ADODB.recordset
Dim wd as New Word.application
Dim doc as Word.document
Dim iCnt as integer
Dim sName as string
set cn = currentproject.connection

rs.open "tblWordRecords", cn

Do until rs.eof
sName = rs!WordTemplField
wd.Documents.add(sName)
'<here the code for the actions to document
doc.Saveas "c:\AnyPath\" & _
"Newdoc_" & Format(Now, "ddmmyyy hhmmss") & _
".doc"
rs.movenext
Loop

wd.Quit: set wd = nothing
Set cn = nothing

--
Krgrds,
Perry

System:
Vista/Office Ultimate
VS2005/VSTO2005 SE
 
P

Perry

In this setting, it would be my advise to handle document creation in
Access.
Based on the records retrieved from the table and the mechanism to identify
the
records to Word templates is in place, something like below code do the job
Just by means of example...

Dim cn as ADODB.connection
Dim rs as new ADODB.recordset
Dim wd as New Word.application
Dim doc as Word.document
Dim iCnt as integer
Dim sName as string
set cn = currentproject.connection

rs.open "tblWordRecords", cn

Do until rs.eof
sName = rs!WordTemplField
wd.Documents.add(sName)
'<here the code for the actions to document
doc.Saveas "c:\AnyPath\" & _
"Newdoc_" & Format(Now, "ddmmyyy hhmmss") & _
".doc"
rs.movenext
Loop

wd.Quit: set wd = nothing
Set cn = nothing

--
Krgrds,
Perry

System:
Vista/Office Ultimate
VS2005/VSTO2005 SE
 

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