none
Insert text based on value in a mail merge data source RRS feed

  • Question

  • I have a mail merge document that uses an Excel spreadsheet as a source for the varying values.

    The field I am testing is named Relationship_to_Johnson_Extended_Family.

    I want to have nothing when the field has null content, and the words Your relationship to me:  followed by the value in Relationship_to_Johnson_Extended_Family, when there is content to be used.

    As a start I have just tried to conditionally include the words "Your relationship to me: " but the words are displaying whatever the value is in Relationship_to_Johnson_Extended_Family.

    The code that I have used reads as follows -

    IF "<<Relationship_to_Johnson_Extended_Family>>" = "" "" "Your relationship to me: " \* MERGEFORMAT

    I typed "<<Relationship_to_Johnson_Extended_Family>>" just as a literal; I could not find a way to display a list of field names, from the source spreadsheet, while creating the IF statement.

    This is my first foray into 'programming' in Word; I do lots of it in Excel, though.

    Ideas please.

    Philip

    Bendigo, Victoria


    Philip Hunt Flora Hill, Bendigo, Victoria Webmaster www.howandwhywonderbooks.info (Phase 1 operative)


    Friday, April 19, 2019 12:50 PM

Answers

  • Insert a Relationship_to_Johnson_Extended_Family mergefield, which will look like:
    «Relationship_to_Johnson_Extended_Family»
    Select the field and press Shift-F9 to expose the field code. It will now look like:
    { MERGEFIELD Relationship_to_Johnson_Extended_Family }
    Edit the field code so you end up with:
    { MERGEFIELD Relationship_to_Johnson_Extended_Family \b "Your relationship to me: "}
    Press F9 to update the field display. Done.

    Cheers
    Paul Edstein
    [MS MVP - Word]

    Friday, April 19, 2019 9:20 PM

All replies

  • Insert a Relationship_to_Johnson_Extended_Family mergefield, which will look like:
    «Relationship_to_Johnson_Extended_Family»
    Select the field and press Shift-F9 to expose the field code. It will now look like:
    { MERGEFIELD Relationship_to_Johnson_Extended_Family }
    Edit the field code so you end up with:
    { MERGEFIELD Relationship_to_Johnson_Extended_Family \b "Your relationship to me: "}
    Press F9 to update the field display. Done.

    Cheers
    Paul Edstein
    [MS MVP - Word]

    Friday, April 19, 2019 9:20 PM
  • Thank you very much Paul.

    Cheers

    Philip


    Philip Hunt Flora Hill, Bendigo, Victoria Webmaster www.howandwhywonderbooks.info (Phase 1 operative)

    Saturday, April 20, 2019 1:31 AM