VB6 and using an existing .dot template for Word Mail Merge
I have already done this where I am creating the document from Visual Basic but what I need to know is this.
The users want to be able to create their own template for the Mail Merge then select the path to that document in my app and run the merge process. I have been researching this for 2 weeks and I have found nothing where this can be done. I know it sounds like we are reinventing the wheel or rewriting Microsoft Word but I work with day traders that have very little computer knowledge.
To date I can call the template document and open it in code however I have not been able to physically produce a document with data from the data source in my application.
I have tried several examples from this site and many other sites but nothing appears to work.
Would someone be kind enough to point me in the right direction please.
I'm trying to underxstand your problem.
Do you just need to provide a means to browse for the template file in your VB application? What does you application contribute to the MailMerge process? Do you need VB to run the MailMerge, or is it just emulating a mail merge process?
0
parkstechAuthor Commented:
I have the browse part developed using the Common Dialog control.
I can create the merge document from code with no problem. What they want is to create their own merge templates and then I am suppoased to call the template to run the merge. Thus far I can open the template using the following:
Set odoc = oWord.Documents.Add("F:\Docs\ADMIN\OPS\Client Labels\Labels\REPGEN_ADProj\Dev\merge_template.dot")
It works to this point. I have an ADO datasource already in the code. In this I have a field called "Name" and in the merge template I have a Merge Field called "Name".
I want to populate the existing Merge Field "Name" with the value from the ADO recordset.
I tried this: .Fields.Item(1).Data = "" + adoPrimaryRS.Fields(1).Value + ""
It gives me an error of: Cannot insert data into this field.
If possible I need to know how to update the Merge Field in the template document from the recordset.
Hi Kevin,
At first glance, this looks possible, but complex. It's now 19:44 (7:44pm ) here in the UK, so I'm going off-line now. If no-one else, who is more active in the intervening hours, has substantial input in about 12 hours, I'll try to formulate a more useful answer in my morning.
Graham
0
Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.
' Execute the mail merge.
objWord.MailMerge.Execute Pause:=False '< This runs but a dialog comes up. If I click OK or Cancel the merge completes successfully. I can't get rid of the dialog box and it doesn't give me a clue to what it is expecting.
End Sub
Private Sub Form_Unload(Cancel As Integer)
End
End Sub
0
moduloCommented:
PAQed with points refunded (20)
modulo
Community Support Moderator
0
Question has a verified solution.
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.
One of a set of tools we're offering as a way of saying thank you for being a part of the community.
Do you just need to provide a means to browse for the template file in your VB application? What does you application contribute to the MailMerge process? Do you need VB to run the MailMerge, or is it just emulating a mail merge process?