PRODUCT COMPARISONS

A Comparison Between IronWord & Microsoft.Office.Interop.Word

Published March 12, 2024
Share:

1. Introduction

Many developers work with .NET applications where they need to handle Word documents. This could be for creating reports, processing documents, or generating invoices. Two popular tools for this are Microsoft.Office.Interop.Word and IronWord. Each has its own set of features, pros, and cons.

This article will compare Microsoft.Office.Interop.Word and IronWord. We will look at what each tool offers, how they perform, and in which scenarios they are best used. This should help you decide which tool is better for your specific needs.

2. Microsoft.Office.Interop.Word

A Comparison Between IronWord & Microsoft.Office.Interop.Word: Figure 1 - Microsoft.Office.Interop.Word webpage

Microsoft.Office.Interop.Word is a library that enables .NET applications to interact directly with Microsoft Word documents. It's a key component for developers who need to automate Word document processes or integrate Word document manipulation capabilities into their .NET applications. This library is particularly useful for tasks such as document generation, modification, and formatting within the .NET environment, leveraging the full capabilities of Microsoft Word.

2.1 Key Features

Document Creation and Editing:

Microsoft.Office.Interop.Word provides extensive support for creating and editing Word documents. It allows developers to programmatically add, modify, and delete text, as well as manage document properties such as titles and subjects. This feature is essential for generating dynamic documents based on user input or external data sources.

Formatting and Styles:

The library offers comprehensive options for formatting text, paragraphs, and entire documents. Developers can apply various styles, fonts, colors, and paragraph alignments to create professionally formatted documents. This includes the ability to define and apply custom styles over the default, ensuring that generated documents meet specific branding or design requirements.

Compatibility with Microsoft Word:

As a component of the Microsoft Office suite, Microsoft.Office.Interop.Word ensures high fidelity and compatibility with all features of Microsoft Word. This includes seamless integration with the latest versions of Word, ensuring that documents created or modified through the library are fully compatible with Word's native format.

3. IronWord

A Comparison Between IronWord & Microsoft.Office.Interop.Word: Figure 2 - IronWord webpage

IronWord is a .NET library designed for document manipulation, specifically targeting Word document processing. Unlike Microsoft.Office.Interop.Word, which relies on the Microsoft Office suite, IronWord provides a standalone solution for creating, editing, and converting Word documents within .NET applications. This makes it an attractive option for developers looking for a library that doesn't require Microsoft Word to be installed on the server or client machines.

3.1 Key Features

Standalone Document Processing:

IronWord enables the manipulation of Word documents directly within .NET applications without the need for Microsoft Office Word to be installed. This independence simplifies deployment and reduces the complexity of development environments, especially in server or cloud contexts.

Document Conversion:

A significant capability of IronWord is its support for converting Word documents to other formats, such as PDF, HTML, and plain text. This feature is essential for applications that need to present documents in multiple formats or for web applications that require document content to be displayed in HTML.

Comprehensive Formatting Options:

IronWord offers a wide range of formatting capabilities, allowing developers to apply text styles, add paragraph alignments, and insert elements like tables and images. These options ensure that documents generated or modified by IronWord meet the required visual and structural standards.

Easy Integration with .NET Projects:

Designed with .NET applications in mind, IronWord can be easily integrated into any .NET project through NuGet. Its API is designed to be intuitive for .NET developers, making it straightforward to start working with Word documents.

Cross-Platform Compatibility:

IronWord supports cross-platform development, making it suitable for use in applications targeting various operating systems. This is particularly valuable for projects that need to run on both the Windows operating system and the Linux operating system, or in cloud environments.

4. Creating the .NET Project in Visual Studio

4.1 Open in Visual Studio

Start by launching Microsoft Visual Studio. Upon opening the application, you will be greeted by the start window. This window offers various options to get started, including opening an existing project or creating a new one. For our purpose, you'll focus on initiating a new project.

A Comparison Between IronWord & Microsoft.Office.Interop.Word: Figure 3 - Creating a new project in Visual Studio

4.2 Choosing the Project Type

After clicking on the option to create a new project, Visual Studio presents you with a list of templates. To proceed, select the Console App project.

A Comparison Between IronWord & Microsoft.Office.Interop.Word: Figure 4 - Creating a Console App project

4.3 Configuring the Project

Once you've selected the desired project template, clicking 'Next' takes you to the project configuration screen. Here, you're required to provide essential details about your project. This includes specifying the project name and selecting the location where your project files will be stored, like a program files folder, reserved for internal use by applications.

A Comparison Between IronWord & Microsoft.Office.Interop.Word: Figure 5 - Configuring the project name and file path

The next dialog box involves selecting the target framework. The .NET Framework you choose determines the libraries and APIs available to your application, influencing its compatibility and functionality. Make sure to select a framework version that supports the features you plan to implement in your application, leveraging Visual Studio tools for an optimized development experience.

A Comparison Between IronWord & Microsoft.Office.Interop.Word: Figure 6 - Choosing the appropriate .NET framework

4.4 Creating the Project

After filling out the necessary information and ensuring all settings are correctly adjusted to meet your project's requirements, the final step is to create the project. This is achieved by clicking the 'Create' button. Visual Studio then initializes a new project based on the selected template and configurations. This process may take a few moments, after which your new .NET project will be open and ready for development.

5. Install IronWord Library

This section delves into how you can incorporate the IronWord library into your project using the NuGet Package Manager, the Visual Studio Command Line, and directly download it from the NuGet webpage.

5.1 Using the NuGet Package Manager

The NuGet Package Manager is a user-friendly interface within Visual Studio that allows for the seamless installation of libraries and tools. To install the IronWord library using this method, follow these steps:

  1. Open your project in Visual Studio. Right-click on the project name in the Solution Explorer and select "Manage NuGet Packages..." from the context menu. This action opens the NuGet Package Manager window.
  2. In the NuGet Package Manager window, navigate to the "Browse" tab. Use the search box to find the IronWord library by entering "IronWord" and pressing Enter.

    A Comparison Between IronWord & Microsoft.Office.Interop.Word: Figure 7 - Installing IronWord using the NuGet package manager

  3. From the search results, select the IronWord package. You will see a detailed description and version information. Choose the version that suits your project requirements and click the "Install" button. Visual Studio then handles the download and installation of the library, updating your project references accordingly.

5.2 Using the Visual Studio Command Line

For those who prefer working with command-line tools, Visual Studio offers the Package Manager Console, a PowerShell interface for managing NuGet packages.

  1. Navigate to "Tools" > "NuGet Package Manager" > "Package Manager Console" from the main menu in Visual Studio.
  2. In the console, type the following command and press Enter:

    Install-Package IronWord

    This command fetches the latest version of the IronWord library and incorporates it into your project. You can specify a particular version by adding the -Version parameter followed by the version number.

A Comparison Between IronWord & Microsoft.Office.Interop.Word: Figure 8 - Installing IronWord through the VS command line

5.3 Direct Download from the NuGet Webpage

A Comparison Between IronWord & Microsoft.Office.Interop.Word: Figure 9 - Installing IronWord through the NuGet webpage

If you prefer to manually manage your project's libraries, you can directly download the IronWord package from the NuGet website and add it to your project.

  1. Visit nuget.org and search for the IronWord package. On the package page, find the "Download" link to get the .nupkg file. Save this file to your computer.
  2. Once downloaded, you can add the package to your project manually. This process typically involves extracting the .nupkg file and then to add references to the contained assemblies in your project. However, it's generally more straightforward and less error-prone to use the NuGet Package Manager or the Visual Studio Command Line as described above.

6. Install Microsoft.Office.Interop.Word

This library can be added to your project through various approaches, each suited to different development preferences and requirements.

6.1 Using the NuGet Package Manager

A Comparison Between IronWord & Microsoft.Office.Interop.Word: Figure 10 - Installing Microsoft.Office.Interop.Word through the NuGet package manager

The NuGet Package Manager in Visual Studio is the most straightforward method to add Microsoft.Office.Interop.Word library to your project. Follow these steps:

  1. Open NuGet Package Manager: With your project open in Visual Studio, right-click on the project name in the Solution Explorer. Select "Manage NuGet Packages..." from the context menu to open the NuGet Package Manager window.
  2. Search for the Library: In the NuGet Package Manager window, switch to the "Browse" tab and type "Microsoft.Office.Interop.Word" in the search box. Press Enter to initiate the search.
  3. Install the Package: Find the "Microsoft.Office.Interop.Word" package in the search results, an object that represents the entire document manipulation capability. Review the provided version information and description to ensure it meets your project's needs. Click on the "Install" button to add the library to your project. Visual Studio will handle the package download and installation, updating your project references to include the necessary assembly.

6.2 Using the Visual Studio Command Line

A Comparison Between IronWord & Microsoft.Office.Interop.Word: Figure 11 - Installing Microsoft.Office.Interop.Word through the VS command line

The Package Manager Console, a command-line interface within Visual Studio, offers another way to install Microsoft.Office.Interop.Word library.

  1. Access the Package Manager Console: Go to "Tools" > "NuGet Package Manager" > "Package Manager Console" from the main menu in Visual Studio.
  2. Execute the Installation Command: In the console, type the following command and press Enter:

    Install-Package Microsoft.Office.Interop.Word
  3. This command instructs Visual Studio to fetch the latest version of the library and integrate it into your project. If you need a specific version of the library, you can specify it by appending the -Version parameter followed by the desired version number.

6.3 Direct Download from the NuGet Webpage

A Comparison Between IronWord & Microsoft.Office.Interop.Word: Figure 12 - Installing Microsoft.Office.Interop.Word from the NuGet webpage

For developers who prefer manual management of project dependencies, Microsoft.Office.Interop.Word library can be directly downloaded from the NuGet website.

  1. Download the Package: Navigate to nuget.org and search for "Microsoft.Office.Interop.Word". On the package's page, find the "Download" link to obtain the .nupkg file. Save this file to a known location on your computer.
  2. Manually Add the Package to Your Project: After downloading, the .nupkg file can be manually added to your project. This typically involves extracting the file and adding references to the extracted assemblies in your project. Nonetheless, for ease of use and to minimize potential errors, utilizing the NuGet Package Manager or the Visual Studio Command Line is recommended.

7. Comparison of Advanced Features in IronWord and Microsoft.Office.Interop.Word

7.1 IronWord's Advanced Features

7.1.1 Read & Edit Word Documents

IronWord allows for the reading and modification of Word documents. This includes opening existing documents, making changes, and saving those changes back to the original document or a new file. This feature is essential for applications that need to update documents based on user input or data from other sources.

using IronWord;
using IronWord.Models;
// Initialize with a new document name
WordDocument document = new WordDocument("my_new_document.docx");
// Insert new text content
document.AddText("This is a demonstration of modifying content with IronWord.");
// Save the document with a new filename
document.SaveAs("updated_document.docx");
using IronWord;
using IronWord.Models;
// Initialize with a new document name
WordDocument document = new WordDocument("my_new_document.docx");
// Insert new text content
document.AddText("This is a demonstration of modifying content with IronWord.");
// Save the document with a new filename
document.SaveAs("updated_document.docx");
Imports IronWord
Imports IronWord.Models
' Initialize with a new document name
Private document As New WordDocument("my_new_document.docx")
' Insert new text content
document.AddText("This is a demonstration of modifying content with IronWord.")
' Save the document with a new filename
document.SaveAs("updated_document.docx")
VB   C#

A Comparison Between IronWord & Microsoft.Office.Interop.Word: Figure 13 - Outputted document from the previous code

7.1.2 Edit Page Setup

IronWord enables changing the paper size of a document, accommodating various standards like A4, Letter, or legal. You can adjust the page orientation between portrait and landscape, depending on the document's requirements.

7.1.3 Add Paragraphs

Adding paragraphs programmatically is straightforward with IronWord, making it possible to insert text dynamically based on application logic.

using IronWord;
using IronWord.Models;
// Initialize a new Word document
WordDocument document = new WordDocument();
// Insert text into the document
document.AddText("Exploring IronWord Capabilities");
// Save the document to a new file
document.SaveAs("updated_ironword_document.docx");
using IronWord;
using IronWord.Models;
// Initialize a new Word document
WordDocument document = new WordDocument();
// Insert text into the document
document.AddText("Exploring IronWord Capabilities");
// Save the document to a new file
document.SaveAs("updated_ironword_document.docx");
Imports IronWord
Imports IronWord.Models
' Initialize a new Word document
Private document As New WordDocument()
' Insert text into the document
document.AddText("Exploring IronWord Capabilities")
' Save the document to a new file
document.SaveAs("updated_ironword_document.docx")
VB   C#

A Comparison Between IronWord & Microsoft.Office.Interop.Word: Figure 14 - Outputted document from the previous code

7.1.4 Add & Remove TextRuns

TextRuns represent sections of text with a common set of properties. IronWord allows for adding and removing these, giving developers control over text segmentation and properties.

7.1.5 Add Images

IronWord supports adding images to documents, including specifying their position, wrapping, and size, which enhances the visual appeal and effectiveness of the document.

using IronWord;
using IronWord.Models;
// Initialize a new Word document
WordDocument document = new WordDocument();
// Setup an image
IronWord.Models.Image img = new IronWord.Models.Image("updated_image.jpg");
img.Width = 250; // Width in pixels
img.Height = 250; // Height in pixels
Paragraph para = new Paragraph();
// Incorporate image into paragraph
para.AddImage(img);
// Integrate paragraph into document
document.AddParagraph(para);
// Save the document with a new name
document.SaveAs("updated_save_document.docx");
using IronWord;
using IronWord.Models;
// Initialize a new Word document
WordDocument document = new WordDocument();
// Setup an image
IronWord.Models.Image img = new IronWord.Models.Image("updated_image.jpg");
img.Width = 250; // Width in pixels
img.Height = 250; // Height in pixels
Paragraph para = new Paragraph();
// Incorporate image into paragraph
para.AddImage(img);
// Integrate paragraph into document
document.AddParagraph(para);
// Save the document with a new name
document.SaveAs("updated_save_document.docx");
Imports IronWord
Imports IronWord.Models
' Initialize a new Word document
Private document As New WordDocument()
' Setup an image
Private img As New IronWord.Models.Image("updated_image.jpg")
img.Width = 250 ' Width in pixels
img.Height = 250 ' Height in pixels
Dim para As New Paragraph()
' Incorporate image into paragraph
para.AddImage(img)
' Integrate paragraph into document
document.AddParagraph(para)
' Save the document with a new name
document.SaveAs("updated_save_document.docx")
VB   C#

A Comparison Between IronWord & Microsoft.Office.Interop.Word: Figure 15 - Outtputed document with an image from the previous code

7.1.6 Add Shapes

Shapes can be added to documents with IronWord, including setting the shape type, size, position, and rotation. This adds a layer of visual interest and can be used to highlight information or add decorative elements.

7.1.7 Set Styling

Styling options in IronWord are extensive, covering font family and size, color, and text decorations like bold, italic, strikethrough, underline, superscript, and subscript. This level of control is crucial for maintaining brand standards and ensuring document readability.

using IronSoftware.Drawing;
using IronWord;
using IronWord.Models;
using Color = IronSoftware.Drawing.Color;
// Initialize WordDocument with a file
WordDocument document = new WordDocument("updated_document.docx");
// Create TextRun with modifications
TextRun modifiedTextRun = new TextRun();
modifiedTextRun.Text = "Updated text with IronWord";
modifiedTextRun.Style = new TextStyle()
{
    FontFamily = "Arial",
    FontSize = 48, // Adjusted font size
    TextColor = new IronColor(Color.Blue), 
    IsBold = false, 
    IsItalic = false, 
    IsUnderline = false, 
    IsSuperscript = true, 
    IsStrikethrough = false,
    IsSubscript = true 
};
Paragraph newParagraph = new Paragraph();
// Add modified TextRun to Paragraph
newParagraph.AddTextRun(modifiedTextRun);
// Add new Paragraph to Document
document.AddParagraph(newParagraph);
// Save Document with a new name
document.SaveAs("updated_save_document.docx");
using IronSoftware.Drawing;
using IronWord;
using IronWord.Models;
using Color = IronSoftware.Drawing.Color;
// Initialize WordDocument with a file
WordDocument document = new WordDocument("updated_document.docx");
// Create TextRun with modifications
TextRun modifiedTextRun = new TextRun();
modifiedTextRun.Text = "Updated text with IronWord";
modifiedTextRun.Style = new TextStyle()
{
    FontFamily = "Arial",
    FontSize = 48, // Adjusted font size
    TextColor = new IronColor(Color.Blue), 
    IsBold = false, 
    IsItalic = false, 
    IsUnderline = false, 
    IsSuperscript = true, 
    IsStrikethrough = false,
    IsSubscript = true 
};
Paragraph newParagraph = new Paragraph();
// Add modified TextRun to Paragraph
newParagraph.AddTextRun(modifiedTextRun);
// Add new Paragraph to Document
document.AddParagraph(newParagraph);
// Save Document with a new name
document.SaveAs("updated_save_document.docx");
Imports IronSoftware.Drawing
Imports IronWord
Imports IronWord.Models
Imports Color = IronSoftware.Drawing.Color
' Initialize WordDocument with a file
Private document As New WordDocument("updated_document.docx")
' Create TextRun with modifications
Private modifiedTextRun As New TextRun()
modifiedTextRun.Text = "Updated text with IronWord"
modifiedTextRun.Style = New TextStyle() With {
	.FontFamily = "Arial",
	.FontSize = 48,
	.TextColor = New IronColor(Color.Blue),
	.IsBold = False,
	.IsItalic = False,
	.IsUnderline = False,
	.IsSuperscript = True,
	.IsStrikethrough = False,
	.IsSubscript = True
}
Dim newParagraph As New Paragraph()
' Add modified TextRun to Paragraph
newParagraph.AddTextRun(modifiedTextRun)
' Add new Paragraph to Document
document.AddParagraph(newParagraph)
' Save Document with a new name
document.SaveAs("updated_save_document.docx")
VB   C#

7.1.8 Set Alignments

IronWord supports setting text alignment within the document, including left, center, right, and justified alignments. This is important for both aesthetics and readability.

7.1.10 Add Tables

Tables are a vital component of many documents, used for organizing data and information. IronWord allows for adding tables and manipulating their structure, including adding or removing rows and columns. Manipulating the content of table cells is straightforward with IronWord, enabling dynamic content insertion based on application needs. IronWord provides the ability to merge and split table cells, which is useful for customizing table layouts and addressing complex data presentation requirements.

using IronWord;
using IronWord.Models;
// Create table cell
TableCell cell = new TableCell();
TextRun textRun = new TextRun();
textRun.Text = "Updated content"; // Changed the text content
// Add TextRun to the cell
cell.AddContent(new Paragraph(textRun));
// Configure border style
BorderStyle borderStyle = new BorderStyle();
borderStyle.BorderColor = new IronColor(IronSoftware.Drawing.Color.Blue); // Changed border color to blue
borderStyle.BorderValue = IronWord.Models.Enums.BorderValues.Double; // Changed border style to double
borderStyle.BorderSize = 3; // Adjusted border size to 3
// Configure table border
TableBorders tableBorders = new TableBorders() {
    TopBorder = borderStyle,
    RightBorder = borderStyle,
    BottomBorder = borderStyle,
    LeftBorder = borderStyle,
};
cell.Borders = tableBorders;
// Create row and add cell
TableRow row = new TableRow();
row.AddCell(cell);
row.AddCell(cell); 
// Create table and add row
Table table = new Table();
table.AddRow(row);
// Create a new Word document from the table
WordDocument doc = new WordDocument(table);
// Export Word document
doc.SaveAs("UpdatedDocument.docx");
using IronWord;
using IronWord.Models;
// Create table cell
TableCell cell = new TableCell();
TextRun textRun = new TextRun();
textRun.Text = "Updated content"; // Changed the text content
// Add TextRun to the cell
cell.AddContent(new Paragraph(textRun));
// Configure border style
BorderStyle borderStyle = new BorderStyle();
borderStyle.BorderColor = new IronColor(IronSoftware.Drawing.Color.Blue); // Changed border color to blue
borderStyle.BorderValue = IronWord.Models.Enums.BorderValues.Double; // Changed border style to double
borderStyle.BorderSize = 3; // Adjusted border size to 3
// Configure table border
TableBorders tableBorders = new TableBorders() {
    TopBorder = borderStyle,
    RightBorder = borderStyle,
    BottomBorder = borderStyle,
    LeftBorder = borderStyle,
};
cell.Borders = tableBorders;
// Create row and add cell
TableRow row = new TableRow();
row.AddCell(cell);
row.AddCell(cell); 
// Create table and add row
Table table = new Table();
table.AddRow(row);
// Create a new Word document from the table
WordDocument doc = new WordDocument(table);
// Export Word document
doc.SaveAs("UpdatedDocument.docx");
Imports IronWord
Imports IronWord.Models
' Create table cell
Private cell As New TableCell()
Private textRun As New TextRun()
textRun.Text = "Updated content" ' Changed the text content
' Add TextRun to the cell
cell.AddContent(New Paragraph(textRun))
' Configure border style
Dim borderStyle As New BorderStyle()
borderStyle.BorderColor = New IronColor(IronSoftware.Drawing.Color.Blue) ' Changed border color to blue
borderStyle.BorderValue = IronWord.Models.Enums.BorderValues.Double ' Changed border style to double
borderStyle.BorderSize = 3 ' Adjusted border size to 3
' Configure table border
Dim tableBorders As New TableBorders() With {
	.TopBorder = borderStyle,
	.RightBorder = borderStyle,
	.BottomBorder = borderStyle,
	.LeftBorder = borderStyle
}
cell.Borders = tableBorders
' Create row and add cell
Dim row As New TableRow()
row.AddCell(cell)
row.AddCell(cell)
' Create table and add row
Dim table As New Table()
table.AddRow(row)
' Create a new Word document from the table
Dim doc As New WordDocument(table)
' Export Word document
doc.SaveAs("UpdatedDocument.docx")
VB   C#

A Comparison Between IronWord & Microsoft.Office.Interop.Word: Figure 16 - Outputted document with tables from the previous code

7.2 Microsoft.Office.Interop.Word's Specific Advanced Features

Microsoft.Office.Interop.Word allows for deep integration with Word documents, enabling developers to leverage Word's extensive features programmatically. Below are specific advanced features offered by Microsoft.Office.Interop.Word, distinct from the general capabilities outlined earlier:

7.2.1 Content Controls

Microsoft.Office.Interop.Word supports the addition and manipulation of content controls, which include rich text boxes, combo boxes, date pickers, and checkboxes. These controls can be used to create structured and interactive documents where users can input or select information within a set template.

// Content Controls
var application = new Microsoft.Office.Interop.Word.Application();
var document = application.Documents.Add();
var cc = document.ContentControls.Add(WdContentControlType.wdContentControlComboBox, ref missing);
cc.Title = "Choose an option";
cc.DropdownListEntries.Add("Option 1", "1");
cc.DropdownListEntries.Add("Option 2", "2");
// Content Controls
var application = new Microsoft.Office.Interop.Word.Application();
var document = application.Documents.Add();
var cc = document.ContentControls.Add(WdContentControlType.wdContentControlComboBox, ref missing);
cc.Title = "Choose an option";
cc.DropdownListEntries.Add("Option 1", "1");
cc.DropdownListEntries.Add("Option 2", "2");
' Content Controls
Dim application = New Microsoft.Office.Interop.Word.Application()
Dim document = application.Documents.Add()
Dim cc = document.ContentControls.Add(WdContentControlType.wdContentControlComboBox, missing)
cc.Title = "Choose an option"
cc.DropdownListEntries.Add("Option 1", "1")
cc.DropdownListEntries.Add("Option 2", "2")
VB   C#

A Comparison Between IronWord & Microsoft.Office.Interop.Word: Figure 17 - Outputted document with content controls from the previous code

7.2.2 Mail Merge

Automate the mail merge process, which combines a Word document with a data source like a spreadsheet or database, to produce personalized letters, labels, or emails in bulk. This feature is invaluable for generating customized communication or documents en masse.

// Mail Merge
var mailMergeDoc = application.Documents.Add();
mailMergeDoc.MailMerge.OpenDataSource("path\\to\\datasource.xlsx");
mailMergeDoc.MailMerge.Destination = WdMailMergeDestination.wdSendToNewDocument;
mailMergeDoc.MailMerge.Execute(false);
// Mail Merge
var mailMergeDoc = application.Documents.Add();
mailMergeDoc.MailMerge.OpenDataSource("path\\to\\datasource.xlsx");
mailMergeDoc.MailMerge.Destination = WdMailMergeDestination.wdSendToNewDocument;
mailMergeDoc.MailMerge.Execute(false);
' Mail Merge
Dim mailMergeDoc = application.Documents.Add()
mailMergeDoc.MailMerge.OpenDataSource("path\to\datasource.xlsx")
mailMergeDoc.MailMerge.Destination = WdMailMergeDestination.wdSendToNewDocument
mailMergeDoc.MailMerge.Execute(False)
VB   C#

7.2.3 Track Changes and Comments

Enable and interact with Word's track changes and comments features through code. This functionality is essential for applications that require collaborative editing, document review, or auditing changes over time.

// Track Changes and Comments
document.TrackRevisions = true;
document.Comments.Add(document.Paragraphs [1].Range, "This is a comment.");
// Track Changes and Comments
document.TrackRevisions = true;
document.Comments.Add(document.Paragraphs [1].Range, "This is a comment.");
' Track Changes and Comments
document.TrackRevisions = True
document.Comments.Add(document.Paragraphs (1).Range, "This is a comment.")
VB   C#

A Comparison Between IronWord & Microsoft.Office.Interop.Word: Figure 18 - Outputted document with comment tracking from the previous code

7.2.4 Headers and Footers

Manipulate headers and footers dynamically, including adding page numbers, dates, or custom text. This is vital for creating professional documents with consistent branding and navigation aids.

// Headers and Footers
foreach (Section section in document.Sections)
{
    section.Headers [WdHeaderFooterIndex.wdHeaderFooterPrimary].Range.Text = "Header Text";
    section.Footers [WdHeaderFooterIndex.wdHeaderFooterPrimary].PageNumbers.Add();
}
// Headers and Footers
foreach (Section section in document.Sections)
{
    section.Headers [WdHeaderFooterIndex.wdHeaderFooterPrimary].Range.Text = "Header Text";
    section.Footers [WdHeaderFooterIndex.wdHeaderFooterPrimary].PageNumbers.Add();
}
' Headers and Footers
For Each section As Section In document.Sections
	section.Headers (WdHeaderFooterIndex.wdHeaderFooterPrimary).Range.Text = "Header Text"
	section.Footers (WdHeaderFooterIndex.wdHeaderFooterPrimary).PageNumbers.Add()
Next section
VB   C#

A Comparison Between IronWord & Microsoft.Office.Interop.Word: Figure 19 - Outputted document with headers and footers from the previous code

7.2.5 Table of Contents and Indexes

Generate and update a table of contents or index based on document headings or marked entries. This is key for creating navigable, professional documents, especially lengthy reports or books.

// Table of Contents and Indexes
var toc = document.TablesOfContents.Add(document.Content, UpperHeadingLevel: 1, LowerHeadingLevel: 3, UseHyperlinks: true);
var index = document.Indexes.Add(document.Content);
// Table of Contents and Indexes
var toc = document.TablesOfContents.Add(document.Content, UpperHeadingLevel: 1, LowerHeadingLevel: 3, UseHyperlinks: true);
var index = document.Indexes.Add(document.Content);
' Table of Contents and Indexes
Dim toc = document.TablesOfContents.Add(document.Content, UpperHeadingLevel:= 1, LowerHeadingLevel:= 3, UseHyperlinks:= True)
Dim index = document.Indexes.Add(document.Content)
VB   C#

7.2.6 Embedding and Linking Objects

Embed or link external objects like Excel charts, PowerPoint presentations, or any other specified object into Word documents. This capability allows for dynamic content that updates with the source file or embedding information directly within the document.

// Embedding and Linking Specified Objects
object missing = System.Reflection.Missing.Value;
document.InlineShapes.AddOLEObject("Excel.Sheet", "path\\to\\excel.xlsx", false, false, ref missing, ref missing, ref missing, ref missing);
// Embedding and Linking Specified Objects
object missing = System.Reflection.Missing.Value;
document.InlineShapes.AddOLEObject("Excel.Sheet", "path\\to\\excel.xlsx", false, false, ref missing, ref missing, ref missing, ref missing);
' Embedding and Linking Specified Objects
Dim missing As Object = System.Reflection.Missing.Value
document.InlineShapes.AddOLEObject("Excel.Sheet", "path\to\excel.xlsx", False, False, missing, missing, missing, missing)
VB   C#

8. Documentation and Support

8.1 IronWord Documentation and Support

IronWord offers thorough documentation and support to aid developers in harnessing its full potential. The documentation encompasses a wide array of resources, including a detailed getting started guide, feature summaries, quick-start examples, and comprehensive API references.

Support for IronWord is robust, providing technical assistance to ensure developers can resolve any issues swiftly. The support framework includes a dedicated team available to address queries and troubleshoot problems.

8.2 Microsoft.Office.Interop.Word Documentation and Support

Microsoft.Office.Interop.Word provides .NET developers with the tools to programmatically interact with Word documents, backed by Microsoft's extensive documentation and support. The documentation includes everything from beginner guides to advanced examples, detailed API information, and practical use cases.

For support, Microsoft offers multiple channels, including direct technical assistance, community forums, and platforms like Stack Overflow for peer support. GitHub is also crucial for reporting issues and suggesting improvements. Regular updates ensure the library stays current with new Word versions, reflecting Microsoft's ongoing commitment to developer needs.

9. Licensing Models

9.1 IronWord License

A Comparison Between IronWord & Microsoft.Office.Interop.Word: Figure 20 - IronWord licensing page

IronWord offers both free and commercial licensing options:

  • Lite License: $749; USD
    • For 1 developer
    • 1 location
    • 1 project
    • E-mail support
  • Plus License: $1,499; USD
    • Up to 3 developers
    • 3 locations
    • 3 projects
    • E-mail (24/7) and chat support
    • Phone support
  • Professional License: $2,999; USD
    • Up to 10 developers
    • 10 locations
    • 10 projects
    • E-mail (24/7), chat, and phone support
    • Screen sharing support

All commercial licenses include priority support and updates. It also offers a free trial to test out all capabilities in a production environment without any watermark.

9.2 Microsoft.Office.Interop.Word License

The licensing for Microsoft.Office.Interop.Word is tied to the Microsoft Office suite. There's no separate license needed for the Interop library itself; it's included with Microsoft Office. The use of Microsoft.Office.Interop.Word in applications requires that the deployment environment has a valid Microsoft Office license, which includes Word.

The cost is dependent on the specific Office suite version and licensing agreement chosen, ranging from individual licenses to volume licensing for businesses. For precise pricing, refer to Microsoft's official website or contact a Microsoft sales representative.

10. Conclusion

In the comparison between IronWord and Microsoft.Office.Interop.Word, we've examined various aspects such as functionality, ease of use, platform compatibility, and licensing. IronWord emerges as a particularly strong contender for developers seeking a flexible, cross-platform solution for Word document manipulation.

With its ability to operate independently of Microsoft Office, IronWord offers a streamlined approach to document processing, making it an ideal choice for applications running in diverse environments. Its comprehensive feature set, combined with the convenience of not requiring Microsoft Word to be installed, gives IronWord an edge, especially in scenarios where deployment simplicity and broad compatibility are key considerations. If you want to buy IronWord, go to the license page.

NEXT >
A Comparison Between IronWord & Aspose Words For .NET

Ready to get started? Version: 2024.10 just released

Free NuGet Download Total downloads: 6,076 View Licenses >