" Live as if you were to die tomorrow. Learn as if you were to live forever.. "
- Mahatma Gandhi

How to get the character count from a Word document

Posted on November 23rd, 2015 by Anusuya Nayak

Sometimes we may need to know the total characters in a word document. We can do this by creating a COM object.. Sample code: $word = new COM(“word.application”) or die(“Unable to instanciate Word”); $word->Visible = 0; $word->Documents->Open(“D:\test\xyz.doc”); // give the path to your word document $total_characters_in doc = $word->ActiveDocument->Characters->Count; $total_paragraph = $word->ActiveDocument->Paragraphs->Count; So now from […]