Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-05-2014, 08:59 AM
taylorblu taylorblu is offline VBA to automatically sort items based on Mail Merge field Windows 8 VBA to automatically sort items based on Mail Merge field Office 2013
Novice
VBA to automatically sort items based on Mail Merge field
 
Join Date: Sep 2014
Posts: 2
taylorblu is on a distinguished road
Default VBA to automatically sort items based on Mail Merge field

I have a quote mail merge template that contains products. In the source, Dynamics CRM, each product contains a sequence number (field). The user is able to modify the order of the products and CRM will adjust the sequence number accordingly. The problem is when the quote is printed, the order of the products always revert back to the original order in which they were entered and not by the sequence number.

In Word, you can manually set the order by opening the 'Edit Recipient List', find the quote_product_sequence_number field column, and sort. But I need this to be automated.

I tried recording a macro as I walked through the manual steps, but the macro does not record anything when the 'Edit Recipient List' dialog box is open.

I tried adding this code ... but I get an 'object required' error.
Sub SequenceOrder()

' Sort by Sequence
sequence = ActiveDocument.MailMerge.DataSource.DataFields("Qu ote_Product_Sequence_Number").Value
sequence.Value.Sort SortOrder:=wdSortOrderAscending

End Sub



Any ideas?
Reply With Quote
  #2  
Old 09-05-2014, 05:32 PM
macropod's Avatar
macropod macropod is offline VBA to automatically sort items based on Mail Merge field Windows 7 64bit VBA to automatically sort items based on Mail Merge field Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 20,497
macropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant future
Default

AFAIK, if you set the sort order via the filters and save the mailmerge main document that way, the same sort order should be retained when you next open the mailmerge main document. You shouldn't need any code for this.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 09-05-2014, 07:20 PM
macropod's Avatar
macropod macropod is offline VBA to automatically sort items based on Mail Merge field Windows 7 64bit VBA to automatically sort items based on Mail Merge field Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 20,497
macropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant future
Default

Cross-posted at: http://answers.microsoft.com/en-us/o...5-80eb6a546396
For cross-posting etiquette, please read: http://www.excelguru.ca/content.php?184
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #4  
Old 09-08-2014, 09:52 AM
taylorblu taylorblu is offline VBA to automatically sort items based on Mail Merge field Windows 8 VBA to automatically sort items based on Mail Merge field Office 2013
Novice
VBA to automatically sort items based on Mail Merge field
 
Join Date: Sep 2014
Posts: 2
taylorblu is on a distinguished road
Default

I thought so too and tried it, but the sort doesn't maintain when the template it run again. I think it refreshes with the new list of recipients.
Reply With Quote
Reply

Tags
mail merge, vba in microsoft word

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mail merge how to link mail merge field value to a column heading dsummers Mail Merge 1 05-08-2014 02:59 PM
VBA to automatically sort items based on Mail Merge field How to ignore a mail merge field if the field is blank redzan Mail Merge 1 05-16-2013 08:34 AM
VBA to automatically sort items based on Mail Merge field Automatically split Mail Merge based on number of pages SaneMan Mail Merge 1 12-03-2011 01:11 AM
dynamic charts based on mail merge fields jwajehee Mail Merge 0 10-05-2011 09:47 AM
VBA to automatically sort items based on Mail Merge field Selecting merge field based on whether or not text is present amym Mail Merge 1 12-07-2010 05:14 AM

Other Forums: Access Forums - Senior Forums

All times are GMT -7. The time now is 08:55 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2020 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft