column order in recipients dialog box

N

nick_coope

The following has been deduced on Word 2002, but possibly applies to some
earlier and later versions. The much later versions may have changed/improved
the facility. The data source was an Excel spreadsheet, but the logic
probably applies to all data sources.

Over the years, there seem to be a few people who have queried the order of
the columns from the data source as displayed in the Mail Merge Recipients
dialog box. Various advice has been given, often (incorrectly) suggesting the
the problem described below is intractable.

Sometimes, the columns seem to be displayed in a 'random' order in the
Recipients dialog, regardless of the order they appear in the data source.
This can be inconvenient if the column(s) required for sorting and/or
filtering do not appear initially within the dialog box window and scrolling
is necessary. It is possible to 'drag' the columns of interest into the
required order, but this new order is not preserved once the dialog is closed,
and is therefore rather pointless.

The problem seems to be caused because Word has an internal 'preferred' order
for the columns based on their likely content (trying to be helpful !!), and
it attempts to arrange the data source columns in this preferred order by
'matching' the data source headers with its notional preferences. This is
quite a difficult task and Word frequently does not do it well. Even if it
were completely successful, it is debatable if the preferred order would suit
most people.

However, it IS possible to change the order of the displayed columns. Word
provides a dialog box that shows the 'mapping' of preferred columns to data
source columns and these CAN be changed by the user. This dialog box appears
only to be accessible from the mail merge toolbar (check
'View/Toolbars/MailMerge' if it not visible). On this toolbar there is an
icon (two boxed lists with red arrows) with the ToolTip 'Match Fields'.
Clicking the icon brings up the Match Fields dialog box.

[NB There does not seem to be a normal main menu route to this dialog. Also,
be wary if you remove this icon from the toolbar using 'Tools/Customise' - it
is not listed under MailMerge commands, but can be found under 'All Commands'
where it is called MailMergeFieldMapping. There is the briefest of mentions
of the Match Fields dialog in the Help file under Mail merge Troubleshooting.]


The Match Fields dialog box lists the Word preferred column types (eg Last
Name, First Name, Courtesy Title, etc) in display order with the
corresponding data source column to the right in a drop down box. The drop
down can be selected to be any of the data source columns. Some items are
shown as '(not available)' and can be selected to have this status by the
user at the bottom of the drop down list. Word first displays (in the Word
column order) those columns that have valid matches, followed by the
remaining columns in the original data source column order.

Thus, even if your data source has many columns in an order determined by
other considerations, you can select columns that are important for mail
merging to appear first in the Recipients display. If your data source
columns are already in the required order, you can simply set all the Word
columns to '(not available)'. Once set, the new field equivalences seem to be
stored with the document.

Anyone interested in writing macros around this topic should investigate the
MailMerge object. For example, the following code will reset all the mappings
to '(not available)' - it gives an error if the active document is not a mail
merge document.

For Each Field In ActiveDocument.MailMerge.DataSource.MappedDataFields
Field.DataFieldIndex = 0
Next Field

I hope this is of assistance to someone!

Nick Coope
 
P

Peter Jamieson

Well researched!

I can confirm that the basic approach works in Word 2003 as well, but
although the match fields facility is there in 2007, it does not affect the
sequence of the fields in the new-style Edit Recipient box in that version.
Also, after 2002 "(not available)" is presented as "(not matched)". I
haven't looked at th VBA qaspects of it.

--
Peter Jamieson
http://tips.pjmsn.me.uk

nick_coope said:
The following has been deduced on Word 2002, but possibly applies to some
earlier and later versions. The much later versions may have
changed/improved
the facility. The data source was an Excel spreadsheet, but the logic
probably applies to all data sources.

Over the years, there seem to be a few people who have queried the order
of
the columns from the data source as displayed in the Mail Merge Recipients
dialog box. Various advice has been given, often (incorrectly) suggesting
the
the problem described below is intractable.

Sometimes, the columns seem to be displayed in a 'random' order in the
Recipients dialog, regardless of the order they appear in the data source.
This can be inconvenient if the column(s) required for sorting and/or
filtering do not appear initially within the dialog box window and
scrolling
is necessary. It is possible to 'drag' the columns of interest into the
required order, but this new order is not preserved once the dialog is
closed,
and is therefore rather pointless.

The problem seems to be caused because Word has an internal 'preferred'
order
for the columns based on their likely content (trying to be helpful !!),
and
it attempts to arrange the data source columns in this preferred order by
'matching' the data source headers with its notional preferences. This is
quite a difficult task and Word frequently does not do it well. Even if it
were completely successful, it is debatable if the preferred order would
suit
most people.

However, it IS possible to change the order of the displayed columns. Word
provides a dialog box that shows the 'mapping' of preferred columns to
data
source columns and these CAN be changed by the user. This dialog box
appears
only to be accessible from the mail merge toolbar (check
'View/Toolbars/MailMerge' if it not visible). On this toolbar there is an
icon (two boxed lists with red arrows) with the ToolTip 'Match Fields'.
Clicking the icon brings up the Match Fields dialog box.

[NB There does not seem to be a normal main menu route to this dialog.
Also,
be wary if you remove this icon from the toolbar using 'Tools/Customise' -
it
is not listed under MailMerge commands, but can be found under 'All
Commands'
where it is called MailMergeFieldMapping. There is the briefest of
mentions
of the Match Fields dialog in the Help file under Mail merge
Troubleshooting.]


The Match Fields dialog box lists the Word preferred column types (eg Last
Name, First Name, Courtesy Title, etc) in display order with the
corresponding data source column to the right in a drop down box. The drop
down can be selected to be any of the data source columns. Some items are
shown as '(not available)' and can be selected to have this status by the
user at the bottom of the drop down list. Word first displays (in the Word
column order) those columns that have valid matches, followed by the
remaining columns in the original data source column order.

Thus, even if your data source has many columns in an order determined by
other considerations, you can select columns that are important for mail
merging to appear first in the Recipients display. If your data source
columns are already in the required order, you can simply set all the Word
columns to '(not available)'. Once set, the new field equivalences seem to
be
stored with the document.

Anyone interested in writing macros around this topic should investigate
the
MailMerge object. For example, the following code will reset all the
mappings
to '(not available)' - it gives an error if the active document is not a
mail
merge document.

For Each Field In ActiveDocument.MailMerge.DataSource.MappedDataFields
Field.DataFieldIndex = 0
Next Field

I hope this is of assistance to someone!

Nick Coope
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top