Compound IF in merge field

J

Jim R

I have been merging Excel to Word2K without a problem. Now what I
want to do is the following:

If PropertyVacant = 1 then "Vacant"
elseif PropertyRented = 1 then "Rented"
else
"Owner Occupied"
endif

The fields PropertyVacant and PeopertyRented are on the merged Excel
file. I want to put the literals on the Word document.

I know I can use VBA but I'm not sure exactly how and were to put it
in VBA.

Any help would be appreciated.
 
G

Greg

Jim,

You can do this with fields in the merge document without
using VBA:

{IF{MergeField PropertyVacant} = "1""Vacant"{IF{MergeField
PropertyRented} = "1""Rented""Owner Occupied"}}
 
G

Graham Mayor

While fields do not require speech mark delimiters, as Greg has shown here,
it makes the construction simpler to follow if they are used
ie
{IF{MergeField fieldname} = "condition" "do this" "otherwise do this"}
Either result can consist of further conditions thus:

{IF{MergeField PropertyVacant} = "1" "Vacant" "{IF{MergeField
PropertyRented} = "1" "Rented" "Owner Occupied"}"}

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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
J

Jim R

I appreciate all the help but it doesn't seem to be working I did a
cut and past and when I do the merge I get PropertyVacant} in the
merged field which is what is shown there before the merge if the
switches aren't showing.

I don't know if this makes a difference or not but the fields being
compared are numeric 0 or 1 but I tried the compares with and without
quotes and the results are the same.

I really would rather not do it with VBA but if I have to I will.

Thanks again for the attempt.

Jim
 
G

Graham Mayor

You can't use cut and paste! The field delimiters {} are not typed from the
keyboard, but set with CTRL+F9.

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


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

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