Consulting

Results 1 to 2 of 2

Thread: SAVING MAIL MERGE LETTERS TO INDIVIDUAL FILES

  1. #1
    VBAX Newbie
    Joined
    Jun 2020
    Posts
    1
    Location

    SAVING MAIL MERGE LETTERS TO INDIVIDUAL FILES

    Hi guys & gals
    I have mail merged a letter that I need to send to employees, but now want the file to save each letter to individual files. To do this it would appear that I need to use a macro, and I am having trouble with a macro I have found that should split the letters into individual files.

    The trouble I am having is the following string:

    ' Get the 1st paragraph
    Set Rng = .Range.Paragraphs(1).Range
    With Rng
    ' Contract the range to exclude the final paragraph break
    .MoveEnd wdCharacter, -1
    StrTxt = .Text
    For k = 1 To Len(StrNoChr)
    StrTxt = Replace(StrTxt, Mid(StrNoChr, k, 1), "_")
    Next
    End With
    ' Construct the destination file path & name
    StrTxt = ActiveDocument.Path & "" & StrTxt
    '*****
    ' Get the whole Section
    Set Rng = .Range
    With Rng
    If j > 1 Then .MoveEnd wdSection, j - 1
    'Contract the range to exclude the Section break
    .MoveEnd wdCharacter, -1
    ' Copy the range
    .Copy ""Surname"" ""Initial""
    End With

    The piece I am having trouble with is shown in red above. Is my problem to do with the first line; Get the 1st paragraph

    Any help you can provide would really be appreciated.

    Many thanks

  2. #2
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,121
    Location
    See Split Merged Output to Separate Documents or, better still, Send Mailmerge Output to Individual Files in the Mailmerge Tips and Tricks thread at:https://www.msofficeforums.com/mail-...ps-tricks.html
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

Tags for this Thread

Posting Permissions

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