Click to See Complete Forum and Search --> : Word & Access Automation ? Please Help !
TWG
July 21st, 1999, 12:22 PM
I am looking for a piece of code that will allow my place of work to be
able to pull data in from an access data base and place it in a standard
letter format. With different case files in the access database, I
would like to be able to ask the given user which case number and then
have the code search the database for that given case number and insert
the information into the fields in the standard letter form.
How do I go about doing this? Is there code already out there? If not,
how hard is it to make this code? Who could I get to do it for me? We
are trying to automate our systems, and from what I have read ... visual
basic seems to be the answer.
J2ms
March 21st, 2000, 02:17 AM
I've had the same problem and I`ve solved it creating labels in the word document.
-Search the information in the DB
-Create an word object
-Replace the labels in word document for your DB information
To create a word object use this code.
Dim xlApp as Object ' Declara la variable para mantener la referencia.
set xlApp = CreateObject("word.application")
' Puede tener la propiedad Visible a true
' si quiere ver la aplicación.
xlApp.Visible = true
' Utiliza xlApp para tener acceso a otros objetos
' de Microsoft word.
'***************************
'SUBSTITUTE THE LABELS PUTTING YOUR INFORMATION
'YOU CAN USE THE FUNCTION REPLACE OF MSWORD
'I SUGESST TOU to MAKE A MACRO IN WORD AND SEE THE CODE GENERATED
'***************************
xlApp.Quit ' Cuando finaliza, utiliza el método Quit para cerrar
set xlApp = nothing ' la aplicación; después libera la referencia.
hedley
March 21st, 2000, 06:31 AM
try to use the VB integrated in Office (ie VBA). the automation may be very complex depending on the degree of flexibility u want yr app to be. But try VBA: it is oriented towards such app
Hedley
Tahbaza
April 3rd, 2000, 11:47 PM
1) Create a UserForm to accept your user's case criteria.
2) Use an ADO recordset object to retrieve the records from the Access DB based on the criteria chosen. (You will need a SQL SELECT statement here and a WHERE clause.)
3) Insert/Replace the retrieved data into your document using Word automation.
Honestly, it would be difficult for someone who does not know VB or Word macros well, (and I don't know you at all).
Good luck /
Email me if you decide to attempt it and have difficulty or would like to contract it.
P.S. Visual Basic is the answer ; )
== Ali R. Tahbaz, MCSD ==========================
"Whether you think that you can, or that you can't, you are usually right."
--Henry Ford
I have encountered the same problem.
WORD DOCUMENT
1. Save the Word Document as a template
2. Place bookmarks in the letter where the information from access should be placed.
ACCESS
1. Create a Form in Access that contains all the information that will be placed in the Word Document.
2. Create a button "Create Word Doc"
3. Use this code to place fields in Word Doc.
Dim obj as Word.Application
Dim varPath as string
'Select the Correct Letter Template
varPath = "\nameoffile.dot"
'Launch Word and the Letter Template
set objWord = new Word.Application
objWord.Documents.Add _
Application.CurrentProject.Path & varPath
obhWord.Visible = true
'Add Information to Word Using Predefined Bookmarks
With objWord.ActiveDocuments.Bookmarks
.Item("NameofBookmark").Range.Text = FieldName
End With
End Sub
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.