Share via

Automatically adding text before content control IF the content control contains a value

Anonymous
2020-05-11T00:15:20+00:00

Hi all,

I've had some success formatting forms to auto populate using mapped content controls (thanks Charles). I am stuck on what I thought would be a simple task. 

Most forms will contain client names. Some will only include one name, and some might include up to 10. I would like to format the forms so that the word "and" appears between all names. The names are each contained in separate content controls. With merge fields, I understand that the switch \b allows the user to specify text that will appear before a field, if and only if the field contains anything. This is essentially what I'm trying to do, but with the field substituted for a content control.

Aside from the obviously wrong formatting, this is how I imagined the field would look.

Using square brackets to represent my [content controls]

[Client1Name] {[Client2Name] /b "and"}

If [Client1Name] was "John Doe" and [Client2Name] was "Jane Doe," the result would simply be "John Doe and Jane Doe" with the "and" automatically inserted by the second mergefield. 

Any thoughts on how this might be done?

Thanks,

Chris

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Anonymous
    2020-05-11T01:05:28+00:00

    Hi

    The \b switch does not work except in mail merges.

    You can use an IF field, but that field will NOT update when you change the value. You can used the mapped content controls but the IF field will not update when the control's value changes. You would need to select all and update the field.

    Take a look at something that is more complex in some ways - the userform.

    That is a custom dialog box created using VBA:

    Create a Simple Userform by Graham Mayor, MVP

    http://www.gmayor.com/Userform.htm

    Create & Employ a Userform by Greg Maxey, MVP

    http://gregmaxey.com/word_tip_pages/create_empl...


    These are links to pages on one or more Word MVP websites. Those pages contain accurate safe information that I think will help you.


    You could add your up to ten people in the userform and then populate your document with those names and appropriate.other text.

    Note "Auto Text" refers to another, completely different, Word feature.

    Automated Boilerplate Using Microsoft Word 

    This forum is a user-to-user support forum. I am a fellow user.

    I hope this information helps.

    Please let me know if you have any more questions or require further help.

    You can ask for more help by replying to this post (Reply button below).

    Regards

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments