Group:  Microsoft Word ยป microsoft.public.word.mailmerge.fields
Thread: Ignore merge field codes when field doesn't exist

Geek News

Ignore merge field codes when field doesn't exist
mcalex 10/29/2008 3:46:05 AM
Hi, I work at a charity, and we have a template letter document that prints
different receipt letters depending on different donations.

Sometimes, raffle tickets will have been purchased, and we need to add the
ticket range info to the letter. The problem is that letters without raffle
ticket information don't have ticket info fields in the data. Therefore, I
get "Error! MergeField was not found in header record of data source" errors.
Is there a way to display field data only if the field actually exists in
the data source? Something like 'if exists {mergefield firstTicket}' or '{if
{mergefield firstTicket } is not null'

thanks for any help
Using:
Word 2003
Win XP Pro
Re: Ignore merge field codes when field doesn't exist
"Doug Robbins - Word MVP" <dkr[ at ]REMOVECAPSmvps.org> 10/29/2008 3:58:18 AM
There is nothing that you can do as part of the built-in mail merge
functionality that can take care of that situation. However, it would be
possible to create a macro that compared the mergefields in the mail merge
main document with those in the data source and take some action in the case
of those that do not exist in the data source. Determining what that action
should be is something to which you would need to give a bit of thought
however, as just deleting (aka ignoring) the mergefield in the document, may
result in a sentence or paragraph appearing out of context or not making
sense.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"mcalex" <mcalex[ at ]discussions.microsoft.com> wrote in message
news:A84C13B3-8440-4BF2-B470-9D55F5D2636C[ at ]microsoft.com...
[Quoted Text]
> Hi, I work at a charity, and we have a template letter document that
> prints
> different receipt letters depending on different donations.
>
> Sometimes, raffle tickets will have been purchased, and we need to add the
> ticket range info to the letter. The problem is that letters without
> raffle
> ticket information don't have ticket info fields in the data. Therefore,
> I
> get "Error! MergeField was not found in header record of data source"
> errors.
> Is there a way to display field data only if the field actually exists in
> the data source? Something like 'if exists {mergefield firstTicket}' or
> '{if
> {mergefield firstTicket } is not null'
>
> thanks for any help
> Using:
> Word 2003
> Win XP Pro


Re: Ignore merge field codes when field doesn't exist
mcalex 10/29/2008 7:56:05 AM
"Doug Robbins - Word MVP" wrote:

[Quoted Text]
> There is nothing that you can do as part of the built-in mail merge
> functionality that can take care of that situation. However, it would be
> possible to create a macro that compared the mergefields in the mail merge

Bummer, didn't think it was going to be easy. OK, I'll fire up VBA. Thanks
Doug.

mcalex

> --
> Hope this helps.
>
> Please reply to the newsgroup unless you wish to avail yourself of my
> services on a paid consulting basis.
>
> Doug Robbins - Word MVP
>
> "mcalex" <mcalex[ at ]discussions.microsoft.com> wrote in message
> news:A84C13B3-8440-4BF2-B470-9D55F5D2636C[ at ]microsoft.com...
> > Hi, I work at a charity, and we have a template letter document that
> > prints
> > different receipt letters depending on different donations.
> >
> > Sometimes, raffle tickets will have been purchased, and we need to add the
> > ticket range info to the letter. The problem is that letters without
> > raffle
> > ticket information don't have ticket info fields in the data. Therefore,
> > I
> > get "Error! MergeField was not found in header record of data source"
> > errors.
> > Is there a way to display field data only if the field actually exists in
> > the data source? Something like 'if exists {mergefield firstTicket}' or
> > '{if
> > {mergefield firstTicket } is not null'
> >
> > thanks for any help
> > Using:
> > Word 2003
> > Win XP Pro
>
>
>

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net