Condition if in Mailmerge from VB

M

Mustapha Amrani

I am doing a mailmerge from VB. I generate a CSV data file first and than
defile the mailmerge document. I would like to have a condition if the
country field is "United Kingdom" omit printing the country and instead have
the postcode.

if {mergefield country}="United Kingdom" {postcode} {country}

How can I do this in the following:

With .Fields
.Add oApp.Selection.Range, "Title"
oApp.Selection.TypeText " "
.Add oApp.Selection.Range, "Initials"
oApp.Selection.TypeText " "
.Add oApp.Selection.Range, "Surname"
oApp.Selection.TypeParagraph
.Add oApp.Selection.Range, "Add1"
oApp.Selection.TypeParagraph
.Add oApp.Selection.Range, "Add2"
oApp.Selection.TypeParagraph
.Add oApp.Selection.Range, "Add3"
oApp.Selection.TypeParagraph
.Add oApp.Selection.Range, "Town_zip"
oApp.Selection.TypeText " "
.Add oApp.Selection.Range, "PostCode"
oApp.Selection.TypeParagraph
.Add oApp.Selection.Range, "Country"

End With

Thanks
 
J

Jean-Guy Marcil

Mustapha Amrani was telling us:
Mustapha Amrani nous racontait que :
I am doing a mailmerge from VB. I generate a CSV data file first and
than defile the mailmerge document. I would like to have a condition
if the country field is "United Kingdom" omit printing the country
and instead have the postcode.

if {mergefield country}="United Kingdom" {postcode} {country}

You will need to use nested fields.
See
http://word.mvps.org/faqs/macrosvba/NestedFieldsWithVBA.htm

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 

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