# Track Changes and Compare Word Documents

Add and read comments and tracked changes, accept or reject revisions by author or type, compare two DOCX versions, and create a redline document.

**Packages**

- [OfficeIMO.Word](https://www.nuget.org/packages/OfficeIMO.Word) `dotnet add package OfficeIMO.Word`

**Works with**

- .NET
- [PowerShell](/docs/pswriteoffice/install/) `Install-Module PSWriteOffice`

**Target frameworks**

netstandard2.0, net10.0, net472

**APIs**

- [`WordDocument`](/api/word/officeimo-word-worddocument/)
- [`WordRevisionFilter`](/api/word/officeimo-word-wordrevisionfilter/)
- [`WordComparisonResult`](/api/word/officeimo-word-wordcomparisonresult/)
- [`WordDocumentComparer`](/api/word/officeimo-word-worddocumentcomparer/)
- [`WordCommentInfo`](/api/word/officeimo-word-wordcommentinfo/)
- [`WordComparisonFinding`](/api/word/officeimo-word-wordcomparisonfinding/)
- [`WordComparisonRedlineMode`](/api/word/officeimo-word-wordcomparisonredlinemode/)
- [`WordComparisonRedlineOptions`](/api/word/officeimo-word-wordcomparisonredlineoptions/)
- [`WordParagraph`](/api/word/officeimo-word-wordparagraph/)
- [`WordReviewInfo`](/api/word/officeimo-word-wordreviewinfo/)
- [`WordRevisionOperationReport`](/api/word/officeimo-word-wordrevisionoperationreport/)

**Cmdlets**

- [`Get-OfficeWordReview`](/api/powershell/get-officewordreview/)
- [`Resolve-OfficeWordRevision`](/api/powershell/resolve-officewordrevision/)
- [`New-OfficeWordRevisionFilter`](/api/powershell/new-officewordrevisionfilter/)
- [`Compare-OfficeDocument`](/api/powershell/compare-officedocument/)
- [`New-OfficeWordComparisonOptions`](/api/powershell/new-officewordcomparisonoptions/)

**Limits**

Newer review extensions that OfficeIMO detects but does not parse are kept in the file and listed in UnsupportedMetadata rather than exposed in the review model. [OfficeIMO.Word support matrix](/compatibility/#package-word)

**Verified**

Examples compiled against the source on 2026-11-14

**Data**

- [OfficeIMO.Word API index](/api/word/index.json)
- [PSWriteOffice command catalog](/data/powershell/commands.json)
- [Capability catalog (JSON)](/data/capabilities.json)

`OfficeIMO.Word` reads the review state of a document without changing it: comments, replies, resolved state, the text they point at, and tracked insertions, deletions, and moves. It can accept or reject revisions selectively, and compare two versions either as structured findings for code or as a redline document for people.

## Add comments and turn on track changes

### C#

```csharp
using OfficeIMO.Word;

using WordDocument document = WordDocument.Create("proposal.docx");

WordParagraph scope = document.AddParagraph("The project covers 12 sites.");
scope.AddComment("Alice Smith", "AS", "Confirm the site count with operations.");

document.TrackChanges = true;
document.Save();
```

## Read comments and tracked changes

`InspectReview` returns a snapshot. Keep `UnsupportedMetadata` in mind: it lists review data in the file that the model does not map.

### C#

```csharp
using OfficeIMO.Word;

using WordDocument document = WordDocument.Load("proposal-reviewed.docx");
WordReviewInfo review = document.InspectReview();

Console.WriteLine($"{review.CommentCount} comments, {review.UnresolvedCommentCount} open, {review.RevisionCount} revisions");
foreach (WordCommentInfo comment in review.Comments) {
    Console.WriteLine($"{comment.Author}: {comment.Text} (on \"{comment.TargetText}\")");
}
```

### PowerShell

```powershell
Get-OfficeWordReview -Path .\proposal-reviewed.docx
```

## Accept or reject tracked changes

Accept or reject everything, or pass a `WordRevisionFilter` to limit the operation by author, revision type, date, or location. The filtered overload returns a report of what changed.

### C#

```csharp
using OfficeIMO.Word;

using WordDocument document = WordDocument.Load("contract-draft.docx");

WordRevisionOperationReport report = document.AcceptRevisions(new WordRevisionFilter { Author = "Legal" });
Console.WriteLine(report);

document.RejectRevisions("External reviewer");
document.Save("contract-clean.docx");
```

### PowerShell

```powershell
$filter = New-OfficeWordRevisionFilter -Author 'Legal'
Resolve-OfficeWordRevision -Path .\contract-draft.docx -OutputPath .\contract-clean.docx -Action Accept -Filter $filter
```

## Compare two versions

`CompareStructure` compares text and order, tables, images, formatting, fields, content controls, bookmarks, hyperlinks, lists, comments, and revisions. Each finding has a stable code, a location, and the old and new text, which suits CI checks and audit reports.

### C#

```csharp
using OfficeIMO.Word;

WordComparisonResult result = WordDocumentComparer.CompareStructure("policy-v1.docx", "policy-v2.docx");

foreach (WordComparisonFinding finding in result.Findings) {
    Console.WriteLine($"{finding.ChangeKind} at {finding.DetailedLocation}: {finding.Message}");
}
File.WriteAllText("policy-changes.md", result.ToMarkdown());
```

### PowerShell

```powershell
$options = New-OfficeWordComparisonOptions -IgnoreWhitespace -NoVolatileMetadata
Compare-OfficeDocument -ReferencePath .\policy-v1.docx -DifferencePath .\policy-v2.docx -Options $options
```

## Create a redline document

A redline is a DOCX for reviewers who work in Word. The default `ReportArtifact` mode writes a review document with a summary, a findings table, and tracked snippets. `InPlaceTarget` copies the new version and applies the supported differences to it as tracked changes.

### C#

```csharp
using OfficeIMO.Word;

WordComparisonResult result = WordDocumentComparer.CreateRedlineDocument(
    "policy-v1.docx", "policy-v2.docx", "policy-redline.docx",
    new WordComparisonRedlineOptions {
        Mode = WordComparisonRedlineMode.InPlaceTarget,
        Author = "Policy review"
    });
Console.WriteLine($"{result.Findings.Count} differences");
```

### PowerShell

```powershell
Compare-OfficeDocument -ReferencePath .\policy-v1.docx -DifferencePath .\policy-v2.docx -OutputPath .\policy-redline.docx
```

<!-- PowerForge markdown source sha256:276C01E4C96876AB4504F245B7858588F00F66F4C05D7F6A0C6F271DC0AC22A0; title=True -->

<!-- PowerForge markdown artifact sha256:C7C240A3DC797A813D2A66B0F28F805CC5CA329DBC138FC4F39A86CE1FAFAA30 -->
