Find Code:
All Words
Any of the Words
Exact Phrase
Home
:
Code
:
Forums
:
Submit
:
Mailing List
:
About
:
Contact
Code
All
VB.NET
ASP.NET
C#
VB Classic
ASP Classic
Snippets
Popular
Resources
Submit Code
Forums
Articles
Tips
Links
Books
Contest
Link to us
Get Page Count
Author:
Gehan Fernando
E-mail:
Click to e-mail author
Submitted:
7/12/2010
Version:
C#
Compatibility:
C#
Category:
File Manipulation
Views:
10798
Get MS Word Document Page Count Programmatically.
Declarations:
using System; using System.Windows.Forms; using Word = Microsoft.Office.Interop.Word;
Code:
namespace PageCount { 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; } } }
Home
|
Forums
|
Submit
|
Books
|
Mailing List
|
Advertising
|
About
|
Contact
© 2024 A1VBCode. All rights reserved.
Legal disclaimer & terms of use
Privacy statement