Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2004

Tip: Looking for answers? Try searching our database.

Condition if in Mailmerge from VB

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mustapha Amrani - 16 Nov 2004 08:21 GMT
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
Jean-Guy Marcil - 17 Nov 2004 02:55 GMT
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

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.