View Single Post
 
Old 11-25-2020, 07:51 AM
joelg joelg is offline Windows 10 Office 2019
Novice
 
Join Date: Nov 2020
Posts: 1
joelg is on a distinguished road
Default How to use Document Properties from Sharepoint in Conditional IF Statements?

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? - SharePoint Stack Exchange

In SharePoint, I have a custom document Content Type that has custom columns / properties, which are passed to the new Word document from it.

Based on those properties, I want the template to 'autofill' text (auto-insert an auto-text). So an example of the logic would be:

If sharePointPropertyGender=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" }

I tested and this seems to work fine with normal DocProperties in MS Word.

Unfortunately, as is well documented (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:





Does anyone have any ideas how to make this work?

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

Thank you in advance! (and apologies for the oversized screenshots)
Reply With Quote