Results 1 to 3 of 3

Thread: Merge / Sort

  1. #1
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    856
    Thanks
    0
    Thanked 9 Times in 8 Posts

    Merge / Sort

    I need to modify VBA code that starts a Word merge. I want to sort the data by LastName field.

    Using:

    Code:
    With ActiveDocument.MailMerge
    .Destination = wdSendToNewDocument
    With DataSource
    .QueryString ???
    End With
    .Execute
    End With
    what replaces ??? to sort the data file by LastName field?

    Thanks,
    Richard

  2. Subscribe to our Windows Secrets Newsletter - It's Free!

    Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,494
    Thanks
    3
    Thanked 139 Times in 132 Posts
    I would try something like the following

    = "SELECT * FROM `tblNameHere` ORDER BY 'LastName'"

    If that doesn't work, I would try recording a macro to see what is captured.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  4. #3
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    856
    Thanks
    0
    Thanked 9 Times in 8 Posts
    Thanks, Andrew. This looks good. I tried recording, and choosing sort/descending from the mailmerge recipients dialog box / refine recipients list. Nothing related to that appeared in the VBA code. What you've suggested is good for me.

    Richard

Posting Permissions

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