Word File Properties

Document properties contain some additional information and details about a file. It's also known as a Word file's metadata and can represent values like author, company, title, and subject. There are two types of document properties, BuiltIn and Custom.

If you need to read and write document properties in Word documents programmatically, you can use the GemBox.Document API in your C# and VB.NET applications.

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

See also


Next steps

GemBox.Document is a .NET component that enables you to read, write, edit, convert, and print document files from your .NET applications using one simple API. How about testing it today?

Download Buy