Search code examples
c#ms-wordword-count

how to get words count from MS Word without carriage return and hidden text using c#


Is that possible to get the words count from the MS Word without the carriage return and hidden text in c#.. I want to get the words count which is shown in Ms word document.. i am using Microsoft.Office.Interop.Word namespace and Using ActiveDocument.Words.Count.. i am getting all the count including the carriage return.. How to get that word count without carriage and hidden text..


Solution

  • This code works..

    int stWordCount = wordobj.ActiveDocument.ComputeStatistics(Word.WdStatistic.wdStatisticWords);