cancel
Showing results for 
Search instead for 
Did you mean: 

Get Number of pages from a Word document

ErjolaMema
Level 5

Hi everyone!

Hope you are doing okay!

I have a question:

How can I get the number of pages into a WORD document?

Thank you for your time!
Erjola



------------------------------
Erjola Mema
------------------------------
1 BEST ANSWER

Best Answers

Hi Erjola,

You can do this in a couple of steps:
  1. Import, or ensure you have, the MS Word VBO from the Program Files
  2. Create a new version of this VBO called "MS Word VBO - Extended" - to align with our best practices
  3. Create a new action called "Count Document Pages" with the following detail:
    1. Inputs: [handle] and [documentName]
    2. Process Flow: Start > Call CheckInstanceHandle Page > Code Stage > End
    3. Code Stage
      1. 'Declare object for code use
        Dim doc as Object = GetDocument(handle,documentName)
        'Returns the number of pages in the document associated with the range (whole document).
        result = doc.Range.Information(4)
    4. Outputs: Result
This will allow you to count the number of pages, if you need any more actions let me know

All the best,

James

------------------------------
James McLintock Program Lead
Intelligent Automation, Program Lead
Blue Prism
Europe/London
------------------------------

View answer in original post

5 REPLIES 5

Hi Erjola,

You can do this in a couple of steps:
  1. Import, or ensure you have, the MS Word VBO from the Program Files
  2. Create a new version of this VBO called "MS Word VBO - Extended" - to align with our best practices
  3. Create a new action called "Count Document Pages" with the following detail:
    1. Inputs: [handle] and [documentName]
    2. Process Flow: Start > Call CheckInstanceHandle Page > Code Stage > End
    3. Code Stage
      1. 'Declare object for code use
        Dim doc as Object = GetDocument(handle,documentName)
        'Returns the number of pages in the document associated with the range (whole document).
        result = doc.Range.Information(4)
    4. Outputs: Result
This will allow you to count the number of pages, if you need any more actions let me know

All the best,

James

------------------------------
James McLintock Program Lead
Intelligent Automation, Program Lead
Blue Prism
Europe/London
------------------------------

Since @James McLintock went through the work of documenting the code to get the page count, we've gone ahead and updated the official MS Word VBO on the Digital Exchange to include this capability.

You can find the latest MS Word VBO here.

NOTE: We went ahead and added actions for getting the count of paragraphs, lines, and words in the document too.

Cheers,


------------------------------
Eric Wilson
Director, Integrations and Enablement
Blue Prism Digital Exchange
------------------------------

ErjolaMema
Level 5

It worked fine!

Thank you @James McLintock !



------------------------------
Erjola Mema
------------------------------

Great !


Thank you @EricWilson1 !​​



------------------------------
Erjola Mema
------------------------------

Thanks @ewilson for sharing latest word VBO with us.

Thanks
Nilesh​

------------------------------
Nilesh Jadhav
Senior RPA Specialist
ADP
India
------------------------------