Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.Application();
Microsoft.Office.Interop.Word.Document doc = new Microsoft.Office.Interop.Word.Document();
try
{
object fileName = @"C:\TT\change.docx";
doc = word.Documents.Open(ref fileName,
ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing);
doc.Activate();
int count = doc.Characters.Count ;
int words = doc.Words.Count; ;
int paragraphs = doc.Paragraphs.Count;
doc.Save();
doc.Close(ref missing, ref missing, ref missing);
word.Application.Quit(ref missing, ref missing, ref missing);
}
catch (Exception ex)
{
doc.Close(ref missing, ref missing, ref missing);
word.Application.Quit(ref missing, ref missing, ref missing);
}
Reference:
http://stackoverflow.com/questions/5824258/programmatically-count-number-of-characters-words-paragraphs-with-a-specific-sty?rq=1
New web site is looking good. Thanks for the great effort. word counter tool
ReplyDelete