0

I would like to create an application that allow users to add user-readable text in word document and at the back end maintain complex text (syntax) like MergeField or Velocity code. e.g. Simple text: Hello Mr. Bob. Complex syntax: Hello «#if($gender == 'Male' Mr. #{else} Ms. #end» Bob

Is this achievable to maintain both simple text view and complex syntax view in single word document?

Thanks

Akhil
  • 11
  • 4
  • If I understand you correctly, yes. The field code is usually hidden... – Cindy Meister Jul 09 '18 at 14:03
  • Hi @CindyMeister, yes, field code is hidden. But when using field code it is displayed as **<<**Userfriendly text**>>** in word. I would like to hide Opening and closing bracket. Thanks, – Akhil Jul 10 '18 at 08:12
  • If you're using Merge fields, and display the *field result* of the linked data source (and that IS how they're intended to be used - with a linked data source), then the brackets aren't visible. If you're NOT linking to an outside data source to execute a mail merge, don't use merge fields. Content Controls would be better suited. Content Controls can be linked to code that can execute on Enter or on Exit. Or they can be linked to a Custom XML Part which offers additional events and possiblities. – Cindy Meister Jul 10 '18 at 14:10

1 Answers1

0

First, you can't have dot in variable name, so let's assume it's saved in $gendervariable.

Second, you can have complex syntax with default of "Hello Mr. Bob" if no gender variable:

Hello #if( $gender == "Female" ) Ms.#{else} Mr.#end Bob

Notice that Mr. is the default text

Ori Marko
  • 56,308
  • 23
  • 131
  • 233