Word Fields returning full merge condition and not just fieldname
I have code that extracts the names of the merge fields in a Word template
This has worked fine but I have now been caught out by people using conditional content based on merge field content
My code uses COM to get the Fields collection and then for each field it gets the Code property to give it the Range and then finally the Text property of the Range
For normal merge fields this gives
MERGEFIELD "FirstName"
I then remove the unwanted characters to leave me with FirstName
Now if the merge field is conditional the Text property contains something like
{ IF { MERGEFIELD Gender } = “Male” “Mr.” “Ms. }
So I can look for MERGEFIELD and take the next word / check for quotes in case of space in name
If that safe?
Are there other types of content that will come back in the Text property that this won't work for?
Thanks