View Single Post
  #1 (permalink)  
Old May 19th, 2006, 07:24 AM
sh.rajkumar sh.rajkumar is offline
Authorized User
Join Date: May 2006
Location: New Delhi, Delhi, India.
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Default character count of ms-word in

Hello ,

In my web Application ,I have to count character in MS-word application using,

I have used stream like

FileStream fin;
            string s;
            char ch;
            int count=0,i;
            fin=new FileStream(@"d:\Test\test.doc",FileMode.Open);
            StreamReader fread=new StreamReader(fin);

But this code is not working as it gives me total 1024 characters whatever characters be in actual document.
Can u give me any solution.

I have tried second way also by using com component of word as

            object filePath="d:\\Test\\test.doc";
            object readOnly=false;
            object missing=System.Reflection.Missing.Value;
            Word.ApplicationClass wa=new Word.ApplicationClass();
            Word.Document cc=wa.Documents.Open(ref filePath,
            ref missing,ref readOnly,ref missing,ref missing,ref missing,ref missing,
            ref missing,ref missing,ref missing,ref missing,ref missing);
            int coun=cc.Characters.Count;
            cc.Close(ref missing,ref missing,ref missing);
            wa.Application.Quit(ref missing,ref missing,ref missing);

but this too is giving errors of some macro.

If u have any solution or suggestion then plz help.

rajkumar sharma
rajkumar sharma