Get MS Word Document Page Count Pro grammatically
Get MS Word Document Page Count Pro grammatically
API Declarations
using System.Windows.Forms;
using Word = Microsoft.Office.Interop.Word;
Rate Get MS Word Document Page Count Pro grammatically
(1(1 Vote))
{
public partial class FormCount : Form
{
public FormCount()
{
InitializeComponent();
}
private void buttonGetCount_Click(object sender, EventArgs e)
{
Word.ApplicationClass WordApp = new Word.ApplicationClass();
object fileName = textBoxPath.Text;
object readOnly = false;
object isVisible = false;
object missing = System.Reflection.Missing.Value;
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, ref missing,
ref missing, ref missing, ref missing);
Word.WdStatistic stat = Word.WdStatistic.wdStatisticPages;
int num = aDoc.ComputeStatistics(stat, ref missing);
MessageBox.Show("The number of pages in doc is " + num.ToString("00"),
this.Text,MessageBoxButtons.OK,MessageBoxIcon.Information);
WordApp = null;
}
}
}
Get MS Word Document Page Count Pro grammatically Comments
No comments yet — be the first to post one!
Post a Comment