We take pride in your success. We let our positivity drive us, day in and out. Talk to us at Mindfire to know us more.

Software Technology Tips

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 the above example,
 
    $total_characters_in doc  will give you the total number of characters including the carriage returns 
    $total_paragraph  will give you the total number of paragraphs in the word document.
     
   If you need to count only the characters and NOT the carriage returns, then you can do this as follows :
 
$only_characters = $total_characters_in doc - $total_paragraph ;
 


Related Tags:

Miscellaneous

Author: Anusuya Nayak

top

Miscellaneous

Let us Connect!

privacy

copyright (c) Mindfire Solutions 2007-2012. Login