Solved CODE Stage to Get page count in MS Word Document

Rushitv

New Member
Hello,

I'm working on a project and as a part of project requirement, I need to get the page count from of each MS world file from the total files. I'm looking for the VBO Code based solution as volume is large for the files. I've below VB code to get the page number for active document but not sure how to use in Code stage.

Sub GetNumberOfPagesInDocument()
MsgBox ActiveDocument.Range.Information(wdNumberOfPagesInDocument)
End Sub

Does anyone know what is the best way to solve this problem?
 

Sachin_Kharmale

Active Member
Hi Rushtiv,

1) For Counting the pages in your Word Document Add New Action "Get Page Count" in your Blue Prism MS Word VBO .
View attachment 1560509631824.png
2) Input to Code Stage will Handle and Document Name which we will get after Create Instance and Open
View attachment 1560509669019.png

3) Code Output will Page Count it will returns page numbers present in word document
View attachment 1560509686549.png
4)Code stage code will be in bellow
View attachment 1560509701938.png
5)Publish action and call from process and get page numbers as output from action "Get Page Count"
View attachment 1560509793929.png
Just add the bellow code in your code stage.
Dim d As Object = GetDocument(handle,document_name)
Count=d.Range.Information(4)


I Hope it will help you.
 

chaitu

New Member
Hi Rushtiv,

1) For Counting the pages in your Word Document Add New Action "Get Page Count" in your Blue Prism MS Word VBO .
View attachment 4068
2) Input to Code Stage will Handle and Document Name which we will get after Create Instance and Open
View attachment 4069

3) Code Output will Page Count it will returns page numbers present in word document
View attachment 4070
4)Code stage code will be in bellow
View attachment 4071
5)Publish action and call from process and get page numbers as output from action "Get Page Count"
View attachment 4072
Just add the bellow code in your code stage.
Dim d As Object = GetDocument(handle,document_name)
Count=d.Range.Information(4)


I Hope it will help you.
Thanks sachin its really helpful.
May i know what is the parameter '4' refers in this line "d.Range.Information(4)"
 

harish17

Active Member
Hi,
Is it possible to identify the page value is displayed or not in the word?

One way is reading Header and Footer in the word and identify it but there is possible it will come as false positive if the header and footer has some numeric values.

Thanks,
Harish
 
Top