Compare Variables and Document Properties

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.

Close
Loading

Analyzing your prompt, please hold on...

An error occurred while retrieving the results. Please refresh the page and try again.