0

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!)

1 Answer 1

0

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 }
1
  • Thanks for the help, it worked! Still not entirely perfect as I find myself having to press "F9" to refresh for the IF statement to take effect, but that's OK.
    – Joel G
    Nov 28, 2020 at 20:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.