Is it possible to implement validation rules in a Word mail merge? I want to set up the Word file so that if a given test fails, Word will take some action when attempting to complete the merge. Here's an example:

I am creating letters for a large excel file of people which will show their name and mailing address at the top. If any record has a blank value for the "Last Name" field, for example, Word will not allow the merge and will instead display a message to the user.

I'm happy to write something in VBA if necessary but I didn't know if Word has any kind of functionality for this sort of purpose. Using Word 2013 but have access to any version 2003+.


  • Wouldn't it make more sense to check the data quality at the data source, i.e. in Excel, before even starting to use the workbook in the mail merge? – teylyn Apr 24 '14 at 4:25
  • @teylyn not in this case. The validation rules will vary depending on which Word file is being used, and all Word files will use the same data. I am expecting that the users will filter the data in Excel but I want Word to ensure that they've done it properly before it allows them to merge. – kad81 Apr 24 '14 at 4:50

Word does have a "Check for errors" feature, but it really only checks for certain types of error, e.g. It will probably pick up a syntax error in an { = } field in the case where the data is not actually numeric.

For certain types of error, you could consider having a test MailMerge document for each real MailMerge document - e.g. Use an IF fieldThe test would explicitly check for a blank Last Name and insert "Error: blank Last Name" in the output. If the user sees no errors in the test, they proceed to the real thing.

But fields can only test so much. Beyond that, VBA is probably the way to go. But then you would need to test the data as Word MailMerge is going to see it, which really means that you need to use the MailMerge.DataSource.Datafields collection to inspect the data for each record. Otherwise, if for example you use OLE Automation to open thw workbook and check the data, you may get different results from when Word Mailmerge opens it using OLE DB. In that case, there is at least one potential problem, which is that data values longer than 255 characters are truncated in DataSource.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.