Forum: Ruby How to Count pages in a word document

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
358a4fdb8939d8fc7ee6a439174c0446?d=identicon&s=25 Talib Hussain (talib)
on 2008-12-12 07:35
Hi,

Could you let me know how can I count the no. of pages in a Word
document using Ruby?

TIA,
Talib Hussain
358a4fdb8939d8fc7ee6a439174c0446?d=identicon&s=25 Talib Hussain (talib)
on 2008-12-12 09:29
Talib Hussain wrote:
> Hi,
>
> Could you let me know how can I count the no. of pages in a Word
> document using Ruby?
>
> TIA,
> Talib Hussain

No replies i am surprised
666b4e17b4bb0e2d999037a25f65a7cb?d=identicon&s=25 Heesob Park (phasis)
on 2008-12-12 10:02
(Received via mailing list)
Hi,

2008/12/12 Talib Hussain <talibhn@gmail.com>:
> Hi,
>
> Could you let me know how can I count the no. of pages in a Word
> document using Ruby?
>
Try this:

require 'win32ole'
word = WIN32OLE.new('word.application')
file = 'c:/work/test.doc'
doc = word.documents.open(file,'ReadOnly' => true)
page = doc.ComputeStatistics(2)   # wdStatisticPages = 2
word.activedocument.close(false)
word.quit
puts page


HTH,

Park Heesob
18d3c84ca5a017fe3e96490afaea28aa?d=identicon&s=25 Richard Conroy (Guest)
on 2008-12-12 10:55
(Received via mailing list)
On Fri, Dec 12, 2008 at 8:54 AM, Heesob Park <phasis@gmail.com> wrote:
> require 'win32ole'
> word = WIN32OLE.new('word.application')
> file = 'c:/work/test.doc'
> doc = word.documents.open(file,'ReadOnly' => true)
> page = doc.ComputeStatistics(2)   # wdStatisticPages = 2
> word.activedocument.close(false)
> word.quit
> puts page
>
>
> HTH,

I have found: http://rubyonwindows.blogspot.com/ to be a great
resource for these kinds of things.
Well worth a look if you are stuck on similar problems.
358a4fdb8939d8fc7ee6a439174c0446?d=identicon&s=25 Talib Hussain (talib)
on 2008-12-12 11:12
Heesob Park wrote:
> Hi,
>
> 2008/12/12 Talib Hussain <talibhn@gmail.com>:
>> Hi,
>>


Thanks a lot .... This has make life easier
Ffd881829651935d986c52d12279befb?d=identicon&s=25 Zhenning Guan (rubyernewbie)
on 2008-12-13 11:30
Talib Hussain wrote:
> Hi,
>
> Could you let me know how can I count the no. of pages in a Word
> document using Ruby?
>
> TIA,
> Talib Hussain
take a look at Ruby cookbook.
This topic is locked and can not be replied to.