Results 1 to 3 of 3

Thread: [WORD] Execute MailMerge in VB6

  1. #1

    Thread Starter
    Junior Member Aeric's Avatar
    Join Date
    Nov 2006
    Posts
    28

    Unhappy [WORD] Execute MailMerge in VB6

    I am trying to use VB6 to open a MailMerge document.
    This Word document is connected to a Text file as datasource.

    When I try to open c:\source\letter1.doc, a message box will pop up:
    Opening this document will run the following SQL command:
    SELECT * FROM c:\source\LETTER1.TXT
    Data from your database will be placed in the document. Do you want to continue?

    [ Show Help >> ]

    [ Yes ] [ No ]
    I want to use VB to execute the mailmerge and generate a new file name mail.doc and show in print preview mode.

    Please help.
    Last edited by Aeric; Jul 21st, 2008 at 03:24 PM. Reason: update link

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: [WORD] Execute MailMerge in VB6

    vb Code:
    1. yourwrdobj.displayalerts = false
    2. set objmrgdoc = yourwrdobj.documents.open(yourfile)

    is this what you want to do?
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    Junior Member Aeric's Avatar
    Join Date
    Nov 2006
    Posts
    28

    Unhappy Re: [WORD] Execute MailMerge in VB6

    Set WordDoc = WordApp.Documents.Open(strWordFile)

    The above code will only open the file as normal Word document, not as Letter (MailMerge).

    How can I execute the document so the fields are shown using VB?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width