• Using a command button to open a merged file

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Using a command button to open a merged file

    Author
    Topic
    #1768384

    A programmer created a database for my company and I added a command button with the following code:
    Dim WOrdApp As New Word.Application
    Dim doc As Word.Document

    WOrdApp.Documents.Open “C:My DocumentsNewClmtwithPCP.doc”
    Set doc = WOrdApp.ActiveDocument
    doc.MailMerge.Execute
    doc.CLOSe SaveChanges:=wdDoNotSaveChanges
    WOrdApp.Visible = True
    WOrdApp.WindowState = wdWindowStateMaximize

    This code worked great in his database but now I am making a database of my own and it won’t work. It won’t even recognize: Dim WordApp As New Word.Document
    It’s like I don’t have the option of Word.Document.
    Any suggestions?
    I just want to open a merged word file from a command button.
    Thanks.

    Viewing 0 reply threads
    Author
    Replies
    • #1779142

      You might need to open a module or code, then select Tools-References.

      Check the box for Microsoft Word Object Library (it will have a version #, depending on which you are using)

      • #1779158

        Thank you! I can now use that code. The only problem is I am merging about 300 letters and it takes 6-7 minutes to merge using my command button. Is there any way to speed things up?

        • #1779206

          One way is to not use Access as the datasource for the mail merge. Instead, export the data to be merged to a Word mailmerge format (that is, tab delimited text) file and make that the source for your merge. I’ve never had much luck trying to do large merges with an Access datasource, although I haven’t tried it with Office 2000, which handles the interaction a little differently. With Office 97, Word launched a second instance of Access to provide its data and between the two (three?) applications, it could bring a PC to its knees (figuratively speaking, of course).

    Viewing 0 reply threads
    Reply To: Using a command button to open a merged file

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: