Count words in a Microsoft Office Word document

Update 2009/11/21: The utility displays the number of pages instead of the number of lines.

Counting words in a Microsoft Office Word document through the Microsoft Office Word application is trivial. Just click on the Word Count option from the Tools menu. Sometimes, though, it would be nice to be able to count and display the number of words in a document through a command line utility like the way Unix’s wc utility does for normal text files.

For that reason, I have written a small utility in C# that does exactly that. It opens Microsoft Office Word documents, counts their lines, words and characters and displays the results. Some code was borrowed from To run the utility you need the Microsoft.Office.Interop.Word.dll somewhere in your PATH. You can download this library by downloading the Microsoft Visual Studio Tools for the Microsoft Office system.

Download the executable utility: wcdoc.exe. It is compiled against Microsoft .NET Framework version 2.0. Or download and compile the source code for yourself: wcdoc.cs.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: