Using a form button to open and insert data into a word doc

AWilderbeast

Registered User.
Local time
Today, 16:40
Joined
Sep 13, 2005
Messages
92
Hi all,
Not sure if this is in the right section but heres my question.

How can i gett a button to open a word document and put in specific information. for example. to send a client a letter, the button would open a word doc with the specfic client data in it.

Also a button to start a mail merge with all client records held on the db.

Thanks for any help
 
You need to do wto things :

- define bookmarks in your MS-Word file where you want to place the data

- code to put the data like :

Set rcs = dbs.OpenRecordset("SELECT teh data you want here")

Dim wd_app As Word.Application
Dim path As String
Dim theTemplate As String
Dim fs As Object
Dim current As Object
Dim address As String

path = ""
theTemplate = "G:\yourfile.dot"

Set wd_app = New Word.Application

wd_app.Documents.Add Template:=theTemplate
wd_app.Visible = True
Set current = wd_app.ActiveDocument


current.FormFields("fldachternaam").Result = rcs!naam
current.FormFields("fldvoornaam").Result = rcs!VOORNAMEN
current.FormFields("fldgeboorteplaats").Result = rcs!GEBOORTEPLAATS
current.FormFields("fldadres").Result = rcs!adres
current.FormFields("fldwoonplaats").Result = rcs!woonplaats
current.FormFields("fldnationaliteit").Result = rcs!NATIONALIT
current.FormFields("fldpostcode").Result = rcs!POSTCODE

Set fs = Nothing
Set wd_app = Nothing
Set current = Nothing


Good luck
 

Users who are viewing this thread

Back
Top Bottom