TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Udit Sharma
NA
149
3.1k
How to get exact no of page , word and character counts
Jul 3 2019 12:02 AM
I just want to get page characteristics. I have tried many scripts but not getting the exact output. My code giving me the following output :
But the exact output in the document is as follows :
Here is my code:
static
void
CountwithInterOp(
object
path)
{
Microsoft.Office.Interop.Word.Application word =
new
Microsoft.Office.Interop.Word.Application();
object
miss = System.Reflection.Missing.Value;
object
readOnly =
true
;
Microsoft.Office.Interop.Word.Document docs = word.Documents.Open(
ref
path,
ref
miss,
ref
readOnly,
ref
miss,
ref
miss,
ref
miss,
ref
miss,
ref
miss,
ref
miss,
ref
miss,
ref
miss,
ref
miss,
ref
miss,
ref
miss,
ref
miss,
ref
miss);
Microsoft.Office.Interop.Word.WdStatistic stat = Microsoft.Office.Interop.Word.WdStatistic.wdStatisticPages;
docs.Activate();
int
numout = docs.ComputeStatistics(stat,
ref
miss);
int
wordcountout = docs.ComputeStatistics(WdStatistic.wdStatisticWords,
ref
miss);
int
CharactersWithSpaces= docs.ComputeStatistics(WdStatistic.wdStatisticCharactersWithSpaces,
ref
miss);
Console.WriteLine(
"Pages: "
+ numout);
Console.WriteLine(
"CharactersWithSpaces: "
+ CharactersWithSpaces);
Console.WriteLine(
"Words: "
+ wordcountout);
Console.ReadLine();
docs.Close(
false
);
}
I have tried with different code with many different dlls but getting the same output.
Reply
Answers (
2
)
how to bind questions and answers from different tables
Error occur while upload files on sftp server using c#