Compare Variables and Document Properties

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Comparison MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-comparison -- dnx GroupDocs.Comparison.Mcp --yes
Folders, licensing and more →

GroupDocs.Comparison for Python via .NET can detect changes in Word document properties — variable, built-in, and custom.

Example: Compare variable and document properties

from groupdocs.comparison import Comparer
from groupdocs.comparison.options import CompareOptions

def compare_variables_and_document_properties():
    with Comparer("./source.docx") as comparer:
        comparer.add("./target.docx")
        options = CompareOptions()
        options.compare_variable_property = True
        options.compare_document_property = True
        comparer.compare("./result.docx", options)

if __name__ == "__main__":
    compare_variables_and_document_properties()

source.docx is the source file used in this example. Click here to download it.

target.docx is the target file used in this example. Click here to download it.

Binary file (DOCX, 26 KB)

Download full output

Use case: ensure key metadata values remain consistent across document versions.

The result is as follows:

Property types

Microsoft Word recognises three property surfaces:

Property typeExamplesCompareOption
Built-in propertiesTitle, Author, Subject, Created, Last modifiedcompare_document_property
Custom propertiesAny user-defined key/value pair (Department, Project code)compare_document_property
Document variablesMail-merge fields, automation variables set via VBA / templating toolscompare_variable_property

compare_document_property = True covers built-in AND custom properties. compare_variable_property = True specifically targets the document-variables surface — this is most useful when comparing generated documents (mail-merge output, templating engines like Jinja-into-Word) where the variable values are the meaningful diff.