If you want to get count of total characters in any word document at run time in .net, you can use following code samples.
Code Sample :
[vb.net]
vb.net code for finding count of characters in word document.
Private Function GetCharectorsCount() As Integer Dim objWord As Word.Application Dim objDoc As Word.Document objWord = CreateObject("Word.Application") objDoc = objWord.Documents.Open("D:\Test.docx") Dim TotalCount As Integer = objDoc.Characters.Count Return TotalCount End Function
[c#]
C# code for finding count of characters in word document.
private static int GetWordCharacters() { object objMissing = System.Reflection.Missing.Value; Microsoft.Office.Interop.Word._Application objWord; Microsoft.Office.Interop.Word._Document objDoc; objWord = new Microsoft.Office.Interop.Word.Application(); object fileName = @"D:\Test.docx"; objDoc=objWord.Documents.Open(ref fileName, ref objMissing, ref objMissing, ref objMissing, ref objMissing, ref objMissing, ref objMissing, ref objMissing, ref objMissing, ref objMissing, ref objMissing, ref objMissing, ref objMissing, ref objMissing, ref objMissing, ref objMissing); int totalCount = objDoc.Characters.Count; return totalCount; }
Note:
All characters in the document are counted, including spaces, paragraph marks, and other characters that are normally hidden. Even a new, blank document returns a count of one character because it contains a paragraph mark.