Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Jan 2009
    Location
    Rye, Victoria, Australia
    Posts
    152
    Thanks
    12
    Thanked 0 Times in 0 Posts
    Hello again, Colleagues All,

    I have had several recent posts relating to a mailmerge facility and have received some excellent advice, which I have used to good effect. Now I am getting to the end of it, I am having a little procedural problem.

    The general architecture is that all templates are kept in a central library folder. When a user (working in Access) selects a letter or a document to send to a client or batch of clients and then clicks on the Preview or Print button, the system will copy the template into the user's work area, giving it an assigned name indicating the letter type, the client and the date. A data source is extracted using a query and the merge takes place.

    My problem is that I simply want the merge to take place in the local version of the template. However, the system will display the merged file correctly, but under a default name of Letter1 or whatever. If I want to save it I have to use that name or manually create a name. I attach a word doc with some code which illustrates what I am trying to do. Some commented out lines show some of the attempts I made to get what I want.

    One alternative would be to copy the template but still keep the template name, after which I would like to assign the output file name (instead of Letter1) automatically, using VBA, but I cannot find any function which does this. It would have been nice for instance if the wdSendToNewDocument command took a filename as an argument.

    Can anyone help ?
    Attached Files Attached Files

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Word always gives the document created by mail merge a generic name. After wdDoc.MailMerge.Execute, the resulting document will be the ActiveDocument, and you'll have to work with that. This document has not been saved yet, so you'll have to use ActiveDocument.SaveAs to save it. You can close wDoc without saving it.

  3. #3
    2 Star Lounger
    Join Date
    Jan 2009
    Location
    Rye, Victoria, Australia
    Posts
    152
    Thanks
    12
    Thanked 0 Times in 0 Posts
    Good advice as always, Hans. It worked a charm.

    What I do is copy the template. (keeping the name the same) to the working directory. Then I perform the mail-merge and do the Save As before making it visible. In Preview mode, the user sees the renamed file, can edit it and/or print it as though in normal Word. After closing the Word file, the Access form reappears. In Print mode, of course, it simply prints the renamed file. Actually on the machine I currently work on, the default printer is CutePDFWriter which creates a PDF file with the same name, though it would in other circumstances simply print it out. Very sweet. Even the most naive user can handle this.

    The only thing I had to add was a cleanup function to delete the template copy and the data source.

    Jim.

Posting Permissions

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