none
Page count in MS documents using C# RRS feed

Answers

  • I assume u are using for .docx (opne xml) file file format. You can verify it using the  Open XML.  Here is one of the simple way.

          WordprocessingDocument doc = WordprocessingDocument.Open(path, false);
          MessageBox.Show(doc.ExtendedFilePropertiesPart.Properties.Pages.InnerText.ToString());

    Here is the open xml sdk help.

    http://msdn.microsoft.com/en-us/library/bb448854.aspx

    • Proposed as answer by Bruce Song Tuesday, June 28, 2011 5:49 AM
    • Marked as answer by Bruce Song Thursday, June 30, 2011 8:28 AM
    Thursday, June 23, 2011 6:38 PM

All replies

  • I assume u are using for .docx (opne xml) file file format. You can verify it using the  Open XML.  Here is one of the simple way.

          WordprocessingDocument doc = WordprocessingDocument.Open(path, false);
          MessageBox.Show(doc.ExtendedFilePropertiesPart.Properties.Pages.InnerText.ToString());

    Here is the open xml sdk help.

    http://msdn.microsoft.com/en-us/library/bb448854.aspx

    • Proposed as answer by Bruce Song Tuesday, June 28, 2011 5:49 AM
    • Marked as answer by Bruce Song Thursday, June 30, 2011 8:28 AM
    Thursday, June 23, 2011 6:38 PM
  • I moved your thread into Word forum.

    Best Regards,


    Larcolais Gong[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, June 24, 2011 5:07 AM
  • You already have an answer for the SDK. If using the Word Object Model, you can use ...
     
        [Document-Ref].Content.Information(wdInformation.wdNumberOfPagesInDocument)
     
    Both solutions give you the value based on the last time Word repaginated the document.
     

    Enjoy,
    Tony
    www.WordArticles.com
    Friday, June 24, 2011 8:54 AM
  • Hi RachanaD,

    What is the status of the problem on your side? If you still show any concern on the post, just feel free to follow up.

    Best Regards,


    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, June 29, 2011 10:50 AM