Compensating for "a" and "an"

  • Thread starter Thanks for the Help
  • Start date
T

Thanks for the Help

I am doing a mailmerge document and need help with a field that will
recognize whether the mergefield result begins with a consonant or a vowel.

For instance the sentance might read "His pet is a <<cat>>." or "His pet is
a <<owl>>. I need a field to substitute "an" for "a" when the mergefield
begins with a consonant. Any ideas?
 
D

Doug Robbins - Word MVP

I think that the only way to deal with this is to include the article in the
data source.

If the data source is a Word document, this could be done using a Wildcard
Replace

See the article "Finding and replacing characters using wildcards" at:

http://www.word.mvps.org/FAQs/General/UsingWildcards.htm

If the data source is not a Word document, you could use a catalog or
directory (depends on the version of Word) mailmerge to get the data source
into a Word table so that Wildcard Replace could be used upon it.


--
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
 
G

Graham Mayor

You could use nested conditional fields top test for the vowels eg

{ IF{ Mergefield Type \*lower} = "a*" "an" "{ IF{ Mergefield Type \*lower} =
"e*" "an" "{ IF{ Mergefield Type \*lower} = "i*" "an" "{ IF{ Mergefield Type
\*lower} = "o*" "an" "{ IF{ Mergefield Type \*lower} = "u*" "an"
"a" }" }" }" }" }


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
M

macropod

A simpler version of Graham's solution:
{IF{Mergefield Type \*lower}<> "a*" {IF{Mergefield Type \*lower}<> "e*"
{IF{Mergefield Type \*lower}<> "i*" {IF{ Mergefield Type \*lower}<> "o*"
IF{Mergefield Type \*lower}<> "u*" a an}}}}}

If you're sure the animal types will always have lower-case letters, you
could delete all the '\*lower' switches too.

Cheers
 
G

Graham Mayor

Simpler? ;)

I prefer to add the \*lower switch when making this type of comparison as I
have been bitten too many times with unfortunate data entry (not mine). At
least this way it should work whatever is entered.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
M

macropod

Only a single a/an result, and 20% fewer characters - mostly unnecessary
quotes & spaces. ||:eek:)}

I do wonder though what the OP will do when he/she finds he/she has an hare
or a ewe!!

Cheers
 
D

Doug Robbins - Word MVP

Or a holy cow?

--
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

macropod said:
Only a single a/an result, and 20% fewer characters - mostly unnecessary
quotes & spaces. ||:eek:)}

I do wonder though what the OP will do when he/she finds he/she has an
hare
or a ewe!!

Cheers

--
macropod
[MVP - Microsoft Word]


Graham Mayor said:
Simpler? ;)

I prefer to add the \*lower switch when making this type of comparison as I
have been bitten too many times with unfortunate data entry (not mine).
At
least this way it should work whatever is entered.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
T

Thanks for the Help

luckily, the animals were only an example :) the actual field result will be
the name of a state, so I will adjust the "lower" accordingly. I knew there
had to be a way to do it. Thank you guys so much for your help.

By the way, I just bought a book on Word VBA. Going to try to beef up my
understanding a bit. Any suggestions for a book that goes through a thorough
discussion of fields and switches?

Doug Robbins - Word MVP said:
Or a holy cow?

--
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

macropod said:
Only a single a/an result, and 20% fewer characters - mostly unnecessary
quotes & spaces. ||:eek:)}

I do wonder though what the OP will do when he/she finds he/she has an
hare
or a ewe!!

Cheers

--
macropod
[MVP - Microsoft Word]


Graham Mayor said:
Simpler? ;)

I prefer to add the \*lower switch when making this type of comparison as I
have been bitten too many times with unfortunate data entry (not mine).
At
least this way it should work whatever is entered.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>


macropod wrote:
A simpler version of Graham's solution:
{IF{Mergefield Type \*lower}<> "a*" {IF{Mergefield Type \*lower}<>
"e*" {IF{Mergefield Type \*lower}<> "i*" {IF{ Mergefield Type
\*lower}<> "o*" IF{Mergefield Type \*lower}<> "u*" a an}}}}}

If you're sure the animal types will always have lower-case letters,
you could delete all the '\*lower' switches too.

Cheers


"Thanks for the Help" <Thanks for the (e-mail address removed)>
wrote in message
I am doing a mailmerge document and need help with a field that will
recognize whether the mergefield result begins with a consonant or a
vowel.

For instance the sentance might read "His pet is a <<cat>>." or "His
pet is a <<owl>>. I need a field to substitute "an" for "a" when
the mergefield begins with a consonant. Any ideas?
 
G

Graham Mayor

No book - but see http://www.gmayor.com/formatting_word_fields.htm

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

luckily, the animals were only an example :) the actual field result
will be the name of a state, so I will adjust the "lower"
accordingly. I knew there had to be a way to do it. Thank you guys
so much for your help.

By the way, I just bought a book on Word VBA. Going to try to beef
up my understanding a bit. Any suggestions for a book that goes
through a thorough discussion of fields and switches?

Doug Robbins - Word MVP said:
Or a holy cow?

--
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

macropod said:
Only a single a/an result, and 20% fewer characters - mostly
unnecessary quotes & spaces. ||:eek:)}

I do wonder though what the OP will do when he/she finds he/she has
an hare
or a ewe!!

Cheers

--
macropod
[MVP - Microsoft Word]


Simpler? ;)

I prefer to add the \*lower switch when making this type of
comparison as I have been bitten too many times with unfortunate
data entry (not mine). At
least this way it should work whatever is entered.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>


macropod wrote:
A simpler version of Graham's solution:
{IF{Mergefield Type \*lower}<> "a*" {IF{Mergefield Type \*lower}<>
"e*" {IF{Mergefield Type \*lower}<> "i*" {IF{ Mergefield Type
\*lower}<> "o*" IF{Mergefield Type \*lower}<> "u*" a an}}}}}

If you're sure the animal types will always have lower-case
letters, you could delete all the '\*lower' switches too.

Cheers


"Thanks for the Help" <Thanks for the
(e-mail address removed)> wrote in message
I am doing a mailmerge document and need help with a field that
will recognize whether the mergefield result begins with a
consonant or a vowel.

For instance the sentance might read "His pet is a <<cat>>." or
"His pet is a <<owl>>. I need a field to substitute "an" for
"a" when the mergefield begins with a consonant. Any ideas?
 
D

Doug Robbins - Word MVP

And fellow MVP, macropod's tutorial at:

http://www.wopr.com/cgi-bin/w3t/showthreaded.pl?Number=249902

--
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

Thanks for the Help said:
luckily, the animals were only an example :) the actual field result will
be
the name of a state, so I will adjust the "lower" accordingly. I knew
there
had to be a way to do it. Thank you guys so much for your help.

By the way, I just bought a book on Word VBA. Going to try to beef up my
understanding a bit. Any suggestions for a book that goes through a
thorough
discussion of fields and switches?

Doug Robbins - Word MVP said:
Or a holy cow?

--
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

macropod said:
Only a single a/an result, and 20% fewer characters - mostly
unnecessary
quotes & spaces. ||:eek:)}

I do wonder though what the OP will do when he/she finds he/she has an
hare
or a ewe!!

Cheers

--
macropod
[MVP - Microsoft Word]


Simpler? ;)

I prefer to add the \*lower switch when making this type of comparison
as
I
have been bitten too many times with unfortunate data entry (not
mine).
At
least this way it should work whatever is entered.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>


macropod wrote:
A simpler version of Graham's solution:
{IF{Mergefield Type \*lower}<> "a*" {IF{Mergefield Type \*lower}<>
"e*" {IF{Mergefield Type \*lower}<> "i*" {IF{ Mergefield Type
\*lower}<> "o*" IF{Mergefield Type \*lower}<> "u*" a an}}}}}

If you're sure the animal types will always have lower-case letters,
you could delete all the '\*lower' switches too.

Cheers


"Thanks for the Help" <Thanks for the
(e-mail address removed)>
wrote in message
I am doing a mailmerge document and need help with a field that
will
recognize whether the mergefield result begins with a consonant or
a
vowel.

For instance the sentance might read "His pet is a <<cat>>." or
"His
pet is a <<owl>>. I need a field to substitute "an" for "a" when
the mergefield begins with a consonant. Any ideas?
 
M

macropod

Doug's pointed you to my date calculations 'tutorial. I've also got another
'tutorial' - on Word field maths - at:
http://www.wopr.com/cgi-bin/w3t/showthreaded.pl?Number=365442
with plenty of examples of what can be done with just a few of the field
switches.

Cheers

--
macropod
[MVP - Microsoft Word]


Thanks for the Help said:
luckily, the animals were only an example :) the actual field result will be
the name of a state, so I will adjust the "lower" accordingly. I knew there
had to be a way to do it. Thank you guys so much for your help.

By the way, I just bought a book on Word VBA. Going to try to beef up my
understanding a bit. Any suggestions for a book that goes through a thorough
discussion of fields and switches?

Doug Robbins - Word MVP said:
Or a holy cow?

--
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

macropod said:
Only a single a/an result, and 20% fewer characters - mostly unnecessary
quotes & spaces. ||:eek:)}

I do wonder though what the OP will do when he/she finds he/she has an
hare
or a ewe!!

Cheers

--
macropod
[MVP - Microsoft Word]


Simpler? ;)

I prefer to add the \*lower switch when making this type of comparison as
I
have been bitten too many times with unfortunate data entry (not mine).
At
least this way it should work whatever is entered.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>


macropod wrote:
A simpler version of Graham's solution:
{IF{Mergefield Type \*lower}<> "a*" {IF{Mergefield Type \*lower}<>
"e*" {IF{Mergefield Type \*lower}<> "i*" {IF{ Mergefield Type
\*lower}<> "o*" IF{Mergefield Type \*lower}<> "u*" a an}}}}}

If you're sure the animal types will always have lower-case letters,
you could delete all the '\*lower' switches too.

Cheers


"Thanks for the Help" <Thanks for the (e-mail address removed)>
wrote in message
I am doing a mailmerge document and need help with a field that will
recognize whether the mergefield result begins with a consonant or a
vowel.

For instance the sentance might read "His pet is a <<cat>>." or "His
pet is a <<owl>>. I need a field to substitute "an" for "a" when
the mergefield begins with a consonant. Any ideas?
 
D

Doug Robbins - Word MVP

One of them is enough to "blow your mind".

--
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

macropod said:
Doug's pointed you to my date calculations 'tutorial. I've also got
another
'tutorial' - on Word field maths - at:
http://www.wopr.com/cgi-bin/w3t/showthreaded.pl?Number=365442
with plenty of examples of what can be done with just a few of the field
switches.

Cheers

--
macropod
[MVP - Microsoft Word]


in
message news:[email protected]...
luckily, the animals were only an example :) the actual field result
will be
the name of a state, so I will adjust the "lower" accordingly. I knew there
had to be a way to do it. Thank you guys so much for your help.

By the way, I just bought a book on Word VBA. Going to try to beef up my
understanding a bit. Any suggestions for a book that goes through a thorough
discussion of fields and switches?

Doug Robbins - Word MVP said:
Or a holy cow?

--
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

Only a single a/an result, and 20% fewer characters - mostly unnecessary
quotes & spaces. ||:eek:)}

I do wonder though what the OP will do when he/she finds he/she has
an
hare
or a ewe!!

Cheers

--
macropod
[MVP - Microsoft Word]


Simpler? ;)

I prefer to add the \*lower switch when making this type of comparison as
I
have been bitten too many times with unfortunate data entry (not mine).
At
least this way it should work whatever is entered.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>


macropod wrote:
A simpler version of Graham's solution:
{IF{Mergefield Type \*lower}<> "a*" {IF{Mergefield Type \*lower}<>
"e*" {IF{Mergefield Type \*lower}<> "i*" {IF{ Mergefield Type
\*lower}<> "o*" IF{Mergefield Type \*lower}<> "u*" a an}}}}}

If you're sure the animal types will always have lower-case letters,
you could delete all the '\*lower' switches too.

Cheers


"Thanks for the Help" <Thanks for the (e-mail address removed)>
wrote in message
I am doing a mailmerge document and need help with a field that will
recognize whether the mergefield result begins with a consonant
or a
vowel.

For instance the sentance might read "His pet is a <<cat>>." or "His
pet is a <<owl>>. I need a field to substitute "an" for "a" when
the mergefield begins with a consonant. Any ideas?
 
G

Graham Mayor

Don't you just hate this man ;)
I have added a link to that tutorial on my
http://www.gmayor.com/formatting_word_fields.htm page. Great stuff!

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
One of them is enough to "blow your mind".


macropod said:
Doug's pointed you to my date calculations 'tutorial. I've also got
another
'tutorial' - on Word field maths - at:
http://www.wopr.com/cgi-bin/w3t/showthreaded.pl?Number=365442
with plenty of examples of what can be done with just a few of the
field switches.

Cheers

--
macropod
[MVP - Microsoft Word]


"Thanks for the Help" <[email protected]>
wrote in
message news:[email protected]...
luckily, the animals were only an example :) the actual field
result will be
the name of a state, so I will adjust the "lower" accordingly. I
knew there had to be a way to do it. Thank you guys so much for
your help. By the way, I just bought a book on Word VBA. Going to try
to beef
up my understanding a bit. Any suggestions for a book that goes
through a thorough discussion of fields and switches?

:

Or a holy cow?

--
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

Only a single a/an result, and 20% fewer characters - mostly
unnecessary quotes & spaces. ||:eek:)}

I do wonder though what the OP will do when he/she finds he/she
has an
hare
or a ewe!!

Cheers

--
macropod
[MVP - Microsoft Word]


Simpler? ;)

I prefer to add the \*lower switch when making this type of
comparison as I have been bitten too many times with unfortunate
data entry (not mine). At
least this way it should work whatever is entered.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>


macropod wrote:
A simpler version of Graham's solution:
{IF{Mergefield Type \*lower}<> "a*" {IF{Mergefield Type
\*lower}<> "e*" {IF{Mergefield Type \*lower}<> "i*" {IF{
Mergefield Type \*lower}<> "o*" IF{Mergefield Type \*lower}<>
"u*" a an}}}}} If you're sure the animal types will always have
lower-case
letters, you could delete all the '\*lower' switches too.

Cheers


"Thanks for the Help" <Thanks for the (e-mail address removed)>
wrote in message
I am doing a mailmerge document and need help with a field
that will recognize whether the mergefield result begins with
a consonant or a
vowel.

For instance the sentance might read "His pet is a <<cat>>."
or "His pet is a <<owl>>. I need a field to substitute "an"
for "a" when the mergefield begins with a consonant. Any
ideas?
 
M

macropod

Thanks guys,

Nice to be appreciated.

Cheers

--
macropod
[MVP - Microsoft Word]


Graham Mayor said:
Don't you just hate this man ;)
I have added a link to that tutorial on my
http://www.gmayor.com/formatting_word_fields.htm page. Great stuff!

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
One of them is enough to "blow your mind".


macropod said:
Doug's pointed you to my date calculations 'tutorial. I've also got
another
'tutorial' - on Word field maths - at:
http://www.wopr.com/cgi-bin/w3t/showthreaded.pl?Number=365442
with plenty of examples of what can be done with just a few of the
field switches.

Cheers

--
macropod
[MVP - Microsoft Word]


"Thanks for the Help" <[email protected]>
wrote in
message luckily, the animals were only an example :) the actual field
result will
be
the name of a state, so I will adjust the "lower" accordingly. I
knew there had to be a way to do it. Thank you guys so much for
your help. By the way, I just bought a book on Word VBA. Going to try
to beef
up my understanding a bit. Any suggestions for a book that goes
through a thorough discussion of fields and switches?

:

Or a holy cow?

--
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

Only a single a/an result, and 20% fewer characters - mostly
unnecessary quotes & spaces. ||:eek:)}

I do wonder though what the OP will do when he/she finds he/she
has an
hare
or a ewe!!

Cheers

--
macropod
[MVP - Microsoft Word]


Simpler? ;)

I prefer to add the \*lower switch when making this type of
comparison as I have been bitten too many times with unfortunate
data entry (not mine). At
least this way it should work whatever is entered.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>


macropod wrote:
A simpler version of Graham's solution:
{IF{Mergefield Type \*lower}<> "a*" {IF{Mergefield Type
\*lower}<> "e*" {IF{Mergefield Type \*lower}<> "i*" {IF{
Mergefield Type \*lower}<> "o*" IF{Mergefield Type \*lower}<>
"u*" a an}}}}} If you're sure the animal types will always have
lower-case
letters, you could delete all the '\*lower' switches too.

Cheers


"Thanks for the Help" <Thanks for the
(e-mail address removed)>
wrote in message
I am doing a mailmerge document and need help with a field
that will recognize whether the mergefield result begins with
a consonant or
a
vowel.

For instance the sentance might read "His pet is a <<cat>>."
or "His pet is a <<owl>>. I need a field to substitute "an"
for "a" when the mergefield begins with a consonant. Any
ideas?
 
C

Charles Kenyon

I've taken my cue from you and added links to my
http://addbalance.com/word/download.htm and
http://addbalance.com/usersguide/fields.htm pages. These documents are great
resources.

--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide




--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.


Graham Mayor said:
Don't you just hate this man ;)
I have added a link to that tutorial on my
http://www.gmayor.com/formatting_word_fields.htm page. Great stuff!

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
One of them is enough to "blow your mind".


macropod said:
Doug's pointed you to my date calculations 'tutorial. I've also got
another
'tutorial' - on Word field maths - at:
http://www.wopr.com/cgi-bin/w3t/showthreaded.pl?Number=365442
with plenty of examples of what can be done with just a few of the
field switches.

Cheers

--
macropod
[MVP - Microsoft Word]


"Thanks for the Help" <[email protected]>
wrote in
message luckily, the animals were only an example :) the actual field
result will
be
the name of a state, so I will adjust the "lower" accordingly. I
knew there had to be a way to do it. Thank you guys so much for
your help. By the way, I just bought a book on Word VBA. Going to try
to beef
up my understanding a bit. Any suggestions for a book that goes
through a thorough discussion of fields and switches?

:

Or a holy cow?

--
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

Only a single a/an result, and 20% fewer characters - mostly
unnecessary quotes & spaces. ||:eek:)}

I do wonder though what the OP will do when he/she finds he/she
has an
hare
or a ewe!!

Cheers

--
macropod
[MVP - Microsoft Word]


Simpler? ;)

I prefer to add the \*lower switch when making this type of
comparison as I have been bitten too many times with unfortunate
data entry (not mine). At
least this way it should work whatever is entered.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>


macropod wrote:
A simpler version of Graham's solution:
{IF{Mergefield Type \*lower}<> "a*" {IF{Mergefield Type
\*lower}<> "e*" {IF{Mergefield Type \*lower}<> "i*" {IF{
Mergefield Type \*lower}<> "o*" IF{Mergefield Type \*lower}<>
"u*" a an}}}}} If you're sure the animal types will always have
lower-case
letters, you could delete all the '\*lower' switches too.

Cheers


"Thanks for the Help" <Thanks for the
(e-mail address removed)>
wrote in message
I am doing a mailmerge document and need help with a field
that will recognize whether the mergefield result begins with
a consonant or
a
vowel.

For instance the sentance might read "His pet is a <<cat>>."
or "His pet is a <<owl>>. I need a field to substitute "an"
for "a" when the mergefield begins with a consonant. Any
ideas?
 

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