Question

My question and objective are very similar to the question at this link, but unfortunately the answer didn't provide enough information for me to implement the proposed solution: How to use Document Properties from Sharepoint in MS Word Field Codes?

In SharePoint I have custom columns / properties passed from a custom Content Type to new document.

Based on those properties, I want the template to 'autofill' text (auto-insert an autotext). Sample logic:

If gender=female, insert paragraph1

I thought I could use the IF statement in MS Word's QuickParts and use DocProperty fields like so:

{ IF { DOCPROPERTY Gender } = "Female" {AUTOTEXT customText} "OTHER TEXT" }

Unfortunately, as is well documented (https://sharepains.com/2018/06/29/sharepoint-online-2016-document-properties-vs-docproperty), SharePoint custom properties aren't related to DocProperties. So the "Gender" property from SharePoint isn't accessible as a DocProperty:

enter image description here enter image description here

Does anyone have any ideas how to make this work?

I have used VBA before, and I am open to using it if absolutely necessary. However, I wanted to avoid it so end-users don't have trouble with macro-disabled files (employees in my organization don't always remember to enable macros for internal macro-enabled documents and then tell me the templates don't work!).

Thanks in advance!

(Apologies for the large photos!)

Was it helpful?

Solution

Here is a workaround:

  1. Add the Gender as a Quick Part to the document.
  2. Create a Bookmark for the Quick Part and give a name, for example, Bookmark1.
  3. Use the Bookmark in the Field Codes. The sample code should be formatted as: { IF Bookmark1 ="Female" A B }
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top