Word Template – Empty/Refresh Field Value in Document Property



We will see how to show nothing on Word document while document property field is empty. Also, we will write one macro to update fields whenever document gets open. I am going to use Sharepoint library so document properties will be my Sharepoint library columns.

Let’s See How to Write Condition in Word Document

Note: You can use a simple Word document to write if condition within it. But here in the example, I am going to show macro. So I am using below macro enabled word document type.
  1. Create one Word document file which has type “Word Macro-Enabled Document“, which has (.docm) extension. It is basically Word file with macro enabled functionality.

    • Upload it into your Sharepoint library (which will work as template library).

    • Word document allows us to write condition within it.


      1. Ctrl + F9 : Creates curly braces which allow us to add condition.
      2. Alt + F9 : Show/Hide all conditions on document.

    • Press ctrl + F9, it will create curly braces in Word document. Write if condition within curly braces. See the below image.

    • Press Alt +F9 to hide all conditions in Word document. Upload it back to Sharepoint library -> Fill out the associated library columns and check its value will be available in the document.

Let’s See Macro Method to Update Fields Whenever Document Gets Open

In my previous blog, user will phase one problem. Whenever fields value gets changed, it will not automatically refresh in document. So we are going to use macro to refresh all fields on document.


Previous blog url : 

  1. Create macro in document.

  2. Edit it into “Microsoft Visual Basic” and write the below method for refresh all the field’s value.

  3. Save it and upload it back to Sharepoint library. So whenever any document is generated through macro enabled template file, the document itself updates all fields when it gets open.

Test the Above Macro Enabled Word Document

  • As per the previous blog, you should upload macro enabled document in template library.
  • You should also update template url in contenttype. Go to content type “Customer_Content_Type” -> Advance settings -> Update template URL (now it is having .docm extension)