Click here to Skip to main content
15,998,673 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm using following function to get the page count but observed the file is getting opened. Actually I'm trying to get only page count by passing the file.

private int getPagecount(string filepath)
{
string MyFileName = filepath;

string execPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase);
var filePath = Path.Combine(execPath, MyFileName);

Microsoft.Office.Interop.Word.Application app = new Word.Application();
Microsoft.Office.Interop.Word.Document doc = app.Documents.Open(filePath);
Word.WdStatistic stat = Word.WdStatistic.wdStatisticPages;
object missing = System.Reflection.Missing.Value;
int num= doc.ComputeStatistics(stat, ref missing);

doc.Close();
doc = null;
return num;

}

Advance Thanks.
Posted

1 solution

Try this
C#
int num= doc.ComputeStatistics(stat, false);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900