1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
Word.ApplicationClass WordApp = new Word.ApplicationClass();
// give any file name of your choice.
object fileName = "D:\\abc\\oop1.doc";
object readOnly = false;
object isVisible = true;
// the way to handle parameters you don't care about in .NET
object missing = System.Reflection.Missing.Value;
// Make word visible, so you can see what's happening
//WordApp.Visible = true;
// Open the document that was chosen by the dialog
Word.Document aDoc = WordApp.Documents.Open(ref fileName,
ref missing,ref readOnly, ref missing,
ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing,
ref missing, ref isVisible);
Word.WdStatistic stat = Word.WdStatistic.wdStatisticPages ;
int num = aDoc.ComputeStatistics(stat,ref missing);
System.Console.WriteLine ("The number of pages in doc is {0}",
num);
System.Console.ReadLine(); |
Partager