- HOW TO ADD VALUES TO DOCUMENT PROPERTIES WORD HOW TO
- HOW TO ADD VALUES TO DOCUMENT PROPERTIES WORD INSTALL
No custom properties? Add the part, and theĬustomProps = document. If the code cannot find a custom properties part, it creates a new part, and adds a new set of properties to the part. Using document = WordprocessingDocument.Open(fileName, True)ĭim customProps = document.CustomFilePropertiesPart Var customProps = document.CustomFilePropertiesPart using (var document = WordprocessingDocument.Open(fileName, true)) Code as follows: Sub testcustdocprop () Dim docprops As DocumentProperties Dim docprop As DocumentProperty Set docprops ThisWorkbook.CustomDocumentProperties Set docprop docprops.Add (Name:'test', LinkToContent:False, Value:'xyz') End Sub. Using the CustomFilePropertiesPart property of theĭocument. I'm trying to add a DocumentProperty to the CustomDocumentProperties collection. The codeĪttempts to retrieve a reference to the custom file properties part by Using the Open method of the WordprocessingDocument class. The code starts by opening the document in read/write mode by The code next interacts with the document that you supplied in the
![how to add values to document properties word how to add values to document properties word](https://docs.valispace.com/vhd/1505165319/image-20210810-144443.png)
Includes the name and the value of the property.įor each property, the XML content includes an fmtid attribute, which is always set to the If you examine the XML content, you will find the following:Įach property in the XML content consists of an XML element that The relevant XML is also extracted and shown here for ease of reading. Open XML SDK Productivity Tool for Microsoft Office The part and the reflected C# code that you can use to generate theįigure 1. The tool displays in the right-hand panes both the XML for Figure 1 shows a test document after you run the code in theĬalling the SetCustomProperty Method section of This toolĮnables you to open a document and view its parts and the hierarchy of Office, shown in Figure 1, to discover how they are stored. You can use the Productivity Tool for Microsoft It is important to understand how custom properties are stored in a word One of these values when you call the method. The SetCustomProperty method requires that you supply
![how to add values to document properties word how to add values to document properties word](https://cdn4syt-solveyourtech.netdna-ssl.com/wp-content/uploads/2016/02/word-2013-stop-document-properties-page-4.jpg)
The sample code also includes an enumeration that defines the possible You must explicitly reference the following assemblies in your project:ĭocumentFormat.OpenXml (installed by the Open XML SDK)ĭirectives or Imports statements to compile
HOW TO ADD VALUES TO DOCUMENT PROPERTIES WORD INSTALL
To use the sample code in this topic, you must install the Open XML SDK 2.5. It contains an example SetCustomProperty method to illustrate this task.
HOW TO ADD VALUES TO DOCUMENT PROPERTIES WORD HOW TO
This topic shows how to use the classes in the Open XML SDK 2.5 for Office to programmatically set a custom property in a word processing document.