This short article gives a quick glance at how to edit Word Metadata using C#. It shares a detailed description of setting the development environment, a list of steps to be performed, and a running sample code to change Word metadata using C#. You will learn to access the custom and built-in properties and edit them as per the application requirements.
Steps to Edit Word Document Metadata using C#
- Add the Aspose.Words for .NET library to the project for editing metadata
- Load the Word file into the Document object and access the custom properties in it
- Update the desired metadata by using the Value property
- Access the built-in document properties
- Update the desired properties using the respective property names
- Save the resultant Word file
These steps summarize the process to develop a Word metadata changer using C#. The process is commenced by loading the target Word file followed by accessing the custom properties collection for editing. Similarly, you may access the built-in properties and modify them by providing the desired property name and setting new data using the value property.
Code to Edit Document Properties in Word using C#
This code demonstrates the process to edit Word metadata using C#. The CustomDocumentProperties collection in the Document class is used for setting the custom properties and the BuiltInDocumentProperties collection is used for setting the built-in properties. You may set different properties like Author, Category, Comments, Company, and CreatedTime to name a few.
This article has taught us to develop a DOCX metadata editor using C#. If you want to learn the process to create a new Word file, refer to the article on how to create Word document in C#.