How to Count pages in a word document

Hi,

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

TIA,
Talib H.

Talib H. wrote:

Hi,

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

TIA,
Talib H.

No replies i am surprised

Hi,

2008/12/12 Talib H. [email protected]:

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

On Fri, Dec 12, 2008 at 8:54 AM, Heesob P. [email protected] 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.

Talib H. wrote:

Hi,

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

TIA,
Talib H.
take a look at Ruby cookbook.

Heesob P. wrote:

Hi,

2008/12/12 Talib H. [email protected]:

Hi,

Thanks a lot … This has make life easier