How to count Words fom .doc or .txt files?
-
Hi, I am facing problem of counting words for .doc or .txt files. I am using following methods , 1. aDoc = wordApp.Documents.Open(ref fileName, ref missing, ref readOnly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref isVisible, ref missing, ref missing, ref missing, ref missing); aDoc.Activate(); aDoc.Select(); int WCnt = aDoc.Content.Words.Count; 2. aDoc = wordApp.Documents.Open(ref fileName, ref missing, ref readOnly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref isVisible, ref missing, ref missing, ref missing, ref missing); aDoc.Activate(); aDoc.Select(); string ToCount = aDoc.Content.Text; int RCount = ToCount.Split('\r').Length; int WCnt = ToCount.Split(' ').Length + RCount; Still it is not counting words properly. Please tell me proper method to count the words in .doc or .txt file correctly. :confused:
#Abhi#