Word File Properties

Document properties contain some additional information and details about a file. It's also known as Word file's metadata and can represent values like author, company, title and subject.

There are two types of document properties, BuiltIn and Custom.

On the following link you can find out how to view or change the properties for an Office file.

The following example shows how you can read and write built-in and custom document properties.

Word file's built-in and custom document properties
Screenshot of document properties from Word file
Upload your file (Drag file here)
using System;
using GemBox.Document;

class Program
{
    static void Main()
    {
        // If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY");

        var document = DocumentModel.Load("%InputFileName%");
        var documentProperties = document.DocumentProperties;

        Console.WriteLine("# Built-in document properties:");

        // Read built-in document properties.
        foreach (var builtinProperty in documentProperties.BuiltIn)
            Console.WriteLine($"{builtinProperty.Key,25}: {builtinProperty.Value}");

        // Write custom document properties.
        documentProperties.Custom.Add("My Custom Property 1", "My Custom Value");
        documentProperties.Custom.Add("My Custom Property 2", 123.4);

        Console.WriteLine();
        Console.WriteLine("# Custom document properties:");

        // Read custom document properties.
        foreach (var customProperty in documentProperties.Custom)
            Console.WriteLine($"{customProperty.Key,25}: {customProperty.Value} [{customProperty.Value.GetType()}]");
    }
}
Imports System
Imports GemBox.Document

Module Program

    Sub Main()

        ' If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY")

        Dim document As DocumentModel = DocumentModel.Load("%InputFileName%")
        Dim documentProperties = document.DocumentProperties

        Console.WriteLine("# Built-in document properties:")

        ' Read built-in document properties.
        For Each builtinProperty In documentProperties.BuiltIn
            Console.WriteLine($"{builtinProperty.Key,25}: {builtinProperty.Value}")
        Next

        ' Write custom document properties.
        documentProperties.Custom.Add("My Custom Property 1", "My Custom Value")
        documentProperties.Custom.Add("My Custom Property 2", 123.4)

        Console.WriteLine()
        Console.WriteLine("# Custom document properties:")

        ' Read custom document properties.
        For Each customProperty In documentProperties.Custom
            Console.WriteLine($"{customProperty.Key,25}: {customProperty.Value} [{customProperty.Value.GetType()}]")
        Next

    End Sub
End Module

Want more?

Next example GitHub

Check the next example or select an example from the menu. You can also download our examples from the GitHub.


Like it?

Download Buy

If you want to try the GemBox.Document yourself, you can download the free version. It delivers the same performance and set of features as the professional version, but with some operations limited. To remove the limitation, you need to purchase a license.