Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variation of Mail Merge

Status
Not open for further replies.

VB400

Programmer
Sep 8, 1999
359
US
<br>
We have created a MS Word template that the users use to create new documents (a questionnaire type of form). We locked the context of the template so that the users may enter data only into specified areas (fields) on the form.<br>
<br>
The user starts Word, asks for new document, she's prompted for the template and she selects the template we designed and starts typing (into the fields).<br>
<br>
Here's the twist...<br>
<br>
Some of the information that they enter into the form already exists in our database (customer information). The users don't want to enter the customer data since it already exists in the database. The question that I have is this:<br>
<br>
If I bring up the customer's record in a window within my VB application, can I somehow (via a command buttom) start a new Word document based on the above mentioned template AND feed that document the customer information from the open record?<br>
<br>
So basically three things:<br>
<br>
1. From my VB app, start Word<br>
2. Begin a new document based on a predefined template<br>
3. Feed data to the new document<br>
<br>
Any help will be greatly appreciated!<br>
<br>
Thanks
 
One way is doing a Mail merge<br>
This depends on what type of Database you are using.<br>
Now your Word doc would have to modified to accept the Mail merge data<br>
It only needs to be set up once.<br>
<br>
The best choice for a database is Access. It works well with VB and Word.<br>
Now If I were doing it I would get rid of VB and use Access and Word.<br>
I would in fact get rid of Word and just use Access.<br>
I have wriiten a Leads database tha tdi djust exacltly what you are doing. Have them find if the customer exists already then fill out a form and then print areport which looks just like your Word doc.<br>
Access is faster easier to troubleshoot and has wizards that make working with data a breeze.<br>
In VB you have to write everything out manually.<br>
I have used all of the se Apps for 7-8 years and find Access much quicker to develope in and make changes to.<br>
Also It takes time to Launch WORD from either and you need a screaming PC to make everybody happy.<br>
A DDE link is the biggest Resource hog on the planet.<br>
<br>
<br>
<p> DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br>
 
<br>
Doug,<br>
<br>
I had this idea to begin with but the customer data being displayed is not in a local database -- it is displayed in the UI tier in a 3-tier client server application. I suppose I can write out the data (from the client machine) to a local Access table and have that feed the Word document but I was hoping for a more direct solution.<br>
<br>
Any other ideas are welcome!<br>
<br>
Thanks
 
Does the 3-tier have a ODBC connector?<br>
Are we talking mainframe database? <p> DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br>
 
<br>
It is an AS/400 database, DB2/400 -- a variation of DB2. However, by design the User Interface does not know anything about the database or where the data is stored.<br>
<br>
For the purpose of this question, I have the data that is needed &quot;in memory&quot;. Is there any way I can send that data to a Word Document?
 
<br>
I think I've got it...<br>
<br>
What I was trying to accomplish is to create a new Word document based on an in-house template. The template is designed as a form whereby the document is locked except for form fields that we designed into the form. Some of the data fields to be entered have already been captured by our VB application. We wanted to create a new document and stuff whatever data we have into that document and save it.<br>
<br>
Here's what I came up with...<br>
<br>
Make a reference to Microsoft Word 8.0 Object Library<br>
<br>
Dim wdApp As Word.Application<br>
Dim wdDoc As Word.Document<br>
<br>
Set wdApp = New Word.Application<br>
wdApp.Visible = False<br>
<br>
Set wdDoc = wdApp.Documents.Add(&quot;c:\MyTemplate.dot&quot;)<br>
wdDoc.SaveAs &quot;c:\MyDocument.doc&quot;<br>
<br>
With wdDoc.FormFields<br>
.Item(1).Result = &quot;John Doe&quot; 'Name<br>
.Item(2).Result = &quot;03/13/2000&quot; 'Date Hired<br>
.Item(3).CheckBox.Value = False 'Rehire<br>
End With<br>
<br>
wdDoc.Save<br>
<br>
wdApp.Quit<br>
Set wdDoc = Nothing<br>
Set wdApp = Nothing<br>
<br>
I would like to thank TCLERE for his/her input on another thread that got me started on the right track.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top