Open MSWord from VB for mail merge

harisri
harisri used Ask the Experts™
on
Hello

I want to open MSWORD document from VB. I have some address in database. These should come as mail merge in the same document. How can I do that. Please help me.

Thanking you,

Harikrishnan
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
In Project References, tick "Microsoft Word Object Library..."

Have a database set up, have a word document set up to mail merge with the database.

Now within VB:

Dim objWord As New Word.Application

objWord.Documents.Open p   'p is Word file
objWord.ActiveDocument.MailMerge.Execute
objWord.Documents.Application.PrintOut (False)
Do
Loop Until objWord.BackgroundPrintingStatus = 0
objWord.Quit (wdDoNotSaveChanges)

Hope this helps

Author

Commented:
I want to create new ms word file and new mail merge data based on the data which is available in vb form. Can you help me please.
Author of the Year 2009

Commented:
Hi harisri,
It appears that you have forgotten to close this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept jarvoid's comment(s) as an answer.

harisri, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept THIS comment as an answer.
==========
DanRollins -- EE database cleanup volunteer

Author

Commented:
hello
I had put this query in this about 6 months back. i have solved this and implemented the project also. Anyway I am greateful to u for showing the courtesy.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial