How to Count pages in a word document

T

Talib Hussain

Hi,

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

TIA,
Talib Hussain
 
H

Heesob Park

Hi,

2008/12/12 Talib Hussain said:
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
 
R

Richard Conroy

Hi,


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,

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.
 
Z

Zhenning Guan

Talib said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,077
Latest member
SangMoor21

Latest Threads

Top