To illustrate how this can be done, I just created a C # console application based on .NET 4.5 and some Microsoft Office 2013 COM objects.
using System; using Microsoft.Office.Interop.Word; namespace WordDocStats { class Program {
To do this, you need to reference the following COM objects:
- Microsoft Office Object Library (version 15.0 in my case)
- Microsoft Word Object Library (version 15.0 in my case)
Two COM objects give you access to the necessary namespaces.
For more information on how to reference the correct assemblies, see the section "3. Setting up the working environment:" at: http://www.c-sharpcorner.com/UploadFile/amrish_deep/WordAutomation05102007223934PM/WordAutomation.aspx
For a quick and more general introduction to Word automation through C # see http://www.dotnetperls.com/word
- UPDATE
The documentation for the Document.ComputeStatistics method, which gives you access to the page account, can be found here: http://msdn.microsoft.com/en-us/library/microsoft.office.tools.word.document.computestatistics.aspx
As you can see from the documentation, the method accepts the WdStatistic enumeration, which allows you to get various types of statistics, for example, the total number of pages. For an overview of the full feature set that you have access to, see the WdStatistic enumeration WdStatistic , which can be found here: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.wdstatistic. aspx
source share