Conditional Formatting In Word

Word templates introduced in CRM Online and CRM 2016 are not the easiest contraptions to edit. One of the questions that popped up in a recent conversation was how to use conditional IF in the document generation.

tl;dr

Conditional formatting in word 2016

Conditional formatting to highlight the cells contains one of several values. In fact, the Conditional Formatting can help you to solve this job, please do with the following steps. First, please create a range name for the specific words list, select the cell text and enter a range name Mylist (you can rename as you need) into the Name box, and press Enter key, see screenshot. 'Conditional formatting' is a feature of Excel, doesn't exist in Word. So if you have to use the feature of Excel in Word, then you can try embedding (copy the table in excel now open the Word doc and try Paste Paste Special select Microsoft Excel Worksheet Object ok).

To refer to the control values after the document has been generated, wrap content controls using bookmarks defined at the control container level.

Longer

  1. Conditional Formatting with Microsoft Word If you’ve ever managed 2 versions of a similar document (esp. In SaaS organizations), then you know how creating multiple versions of the same document for different audiences is a pain.
  2. Another option would be to use a Word document with an OLE Microsoft Excel object. The drawback is the users would need to know how to use this embedded Excel object. The third way you could go is to use Microsoft Excel and use the inbuilt Conditional Formatting of Excel.

CRM fields are defined as Content Controls and in theory we could have written some simple VBA using ContentControl object. Except that CRM does not play nice when generating the document and simply replaces all content controls with the record values.

Conditional Formatting In Word Drop Down List

Formatting

The solution is to wrap the content controls using the bookmarks defined at the container level, i.e. cell, row, paragraph, etc. Then this bookmark can be used as a reference in a conditional expression of the IF field.

Conditional Formatting In Word

Conditional Formatting In Word Mail Merge

For example, to insert conditional text depending on the total invoice value:

Conditional Formatting In Word 2013

  1. Extract the Invoice template that comes with the sample data and save it under a different name.
  2. Open the template, find total amount, select the entire table cell and click Insert > Bookmark.
  3. Type totalbookmark as a bookmark name, click Add.
  4. Delete the words “Thank you for your business” and click Insert > Quick Part > Field.
  5. Select IF field and type the following field code:
    IF totalbookmark > 100 “Thank you for you business!” “Thanks for nothing!”
  6. Click OK. Hint: to see and edit field codes in the document, press Alt-F9.
  7. Save the file and upload to CRM as a new template.
  8. Create an invoice and generate the invoice document.
  9. Enable document for editing, press Ctrl-A to select the entire content and press F9 to refresh the field content
  10. Depending on the total value of the invoice, the document will say “Thank you for your business!” or “Thanks for nothing!”

It’s not a full automation that potentially could be improved with some VBA (I’m not 100% sure if it will work) but it’s a step in the right direction and a cheap way to add some pizazz to your documents.

Comments are closed.