Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / March 2007

Tip: Looking for answers? Try searching our database.

Word and Acess

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Wolfguar - 13 Mar 2007 06:01 GMT
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,
Perry - 13 Mar 2007 11:57 GMT
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

> Hello,
>
[quoted text clipped - 31 lines]
>
> Regards,
Perry - 13 Mar 2007 16:20 GMT
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

> Hello,
>
[quoted text clipped - 31 lines]
>
> Regards,
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.