Click here to Skip to main content
15,867,704 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I am working on a project where I have to create a MSWord document. The text in this document is obtained from a special database. Now what I want is that apart from the visible text, I want to embed some special text (for example, some ids) in MSWord which is never made visible to the user. Basically this text should be saved as a special attribute to the xml tag. Also it should be possible to read back this attribute.

Can someone please guide me. I have tried reading a lot but have no clue still. I do not even know if I can add any such special attribute to . Also if it is possible, then how should I do so.
Posted

1 solution

Hi, to be honest this question lacks some additional information, but I presume you are repeating your previous question.

Well the easiest solution that comes to my mind is to use Hidden Text or TC field, before the embedded text, to store your ids.
But everyone can view this information by pressing "Show/Hide" in MS Word so I do not believe this would work for you.

Another solution that you can try is to create a Custom XML Part in your DOCX, unfortunately I do not have a lot of experience in this part of a DOCX, but I hope this will lead you to the required solution.
Also there are lot of information about it, just search "OpenXml SDK Custom Xml".
In short I believe what you are looking for is these two elements in the DOCX specification under the "Custom Markup":
- customXml (Custom XML Element)
- attr (Custom XML Attribute)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900