Consulting

Results 1 to 7 of 7

Thread: name files after mail merge

  1. #1
    VBAX Newbie
    Joined
    Sep 2005
    Posts
    4
    Location

    name files after mail merge

    Hi
    I have the Excel file and Word file for mail merge, after mail merge, I separte each page using Dreamboat knowledge base entry
    http://vbaexpress.com/kb/getarticle.php?kb_id=139
    Now, I would like to name each file using the street name and fax number (faxnbr).
    humm, I am not sure how to attach Excel and Word to this message.!!!
    please look at the attached zip file: mailmergeExcelWord.zip
    If you cannot open it, please let me know, this is my first time zipping files.

    The outcome four filenames should be something similar to the followings:
    first filename: main128-238-2222
    second filename: south 14th879-888-8777
    third filename: 3rd ave N128-773-8348
    fourth filename:US301 N951-873-8484
    does not have to be exactly like the above, but something that has street name and faxnumber are good enough.
    I really appreciate all the help, all great volunteers.

    Sincerely
    Tom

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Guru MOS MASTER's Avatar
    Joined
    Apr 2005
    Location
    Breda, The Netherlands
    Posts
    3,281
    Location
    Hi and Welcome to VBAX Tom!

    I think what you mean is use some of the mergefield information to build your pathname (document name) right?

    If so then I think that KB is not the right way to go for you cause you allready merged your document.

    I think it's much wiser to let the code do the merge for you and merge each document in to it's rightfull path with the field information used for the pathname.

    That way the code is much more efficient.

    If you like that approach I'll give you a example.
    _________
    Groetjes,

    Joost Verdaasdonk
    M.O.S. Master

    Mark your thread solved, when it has been, by hitting the Thread Tools dropdown at the top of the thread.
    (I don't answer questions asked through E-mail or PM's)

  3. #3
    VBAX Newbie
    Joined
    Sep 2005
    Posts
    4
    Location
    Yes,
    say in my Excel I have column for street name and zipcode, and a lot more
    I do mail merge, at the end of mail merge I click on create new document button.
    I will have a document each page/section is a Word letter with each row of Excel file.
    So this is a very long document if The Excel has a lot of rows.
    So I would like to break this new document into smaller/individual page/section into smaller files and automated the process by naming the file using the row cell of Excel file.
    Please give me an example of your suggestions.
    My results are for each row in the Excel I will have a separate file, instead a huge Word document file. Thank you for your help, I really appreciate it.

  4. #4
    VBAX Newbie
    Joined
    Sep 2005
    Posts
    4
    Location
    would you please give me an example for let the code do the merge..

  5. #5
    VBAX Regular kane's Avatar
    Joined
    Mar 2005
    Location
    Huntsville, AL
    Posts
    35
    Location
    I could use this code too, if posted.

    Thx,

  6. #6
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  7. #7
    VBAX Regular kane's Avatar
    Joined
    Mar 2005
    Location
    Huntsville, AL
    Posts
    35
    Location

    Mail Merge

    Is there any way to change the following code so it names the file the content of column A?


    [VBA]
    Option Explicit

    Sub AllSectionsToSubDoc()

    Dim x As Long
    Dim Sections As Long
    Dim Doc As Document

    Application.ScreenUpdating = False
    Application.DisplayAlerts = False

    Set Doc = ActiveDocument
    Sections = Doc.Sections.Count
    For x = Sections - 1 To 1 Step -1
    Doc.Sections(x).Range.Copy
    Documents.Add
    ActiveDocument.Range.Paste
    ActiveDocument.SaveAs (Doc.Path & "\" & x & ".doc")
    ActiveDocument.Close False
    Next x

    Application.ScreenUpdating = True
    Application.DisplayAlerts = True

    End Sub
    [/VBA]

Posting Permissions

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