Is there a way to identify the end of Nested field code? because we usually find the nested field codes inside TOCs field which has been very difficult for us to programmatically identify its end.
Whenever dealing with fields, and certainly nested fields, I use the FieldRetriever.cs module in Open-Xml-PowerTools. This module retrieves (in nested form) all fields in a DOCX. Further, auxiliary information is in the data structures returned by FieldRetriever, such as object references to the various markup elements in the main document part. You can use those object references to alter / query the document.
The FieldRetriever module serves two purposes – it provides nicely packaged functionality to C# developers to understand the fields in a document, including nested fields. Further, it provides a reference implementation regarding the correct approach for retrieving the instrText and the representation of fields in a document.
Please watch screen-casts #14 and #15 in the following series:
Thanks Eric this was very helpful!
You must be logged in to reply to this topic.