DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

David has posted 23 posts at DZone. View Full User Profile

Ruby & MS Word: Counting Words And Pages

  • submit to reddit
        From the <a href="">Ruby on Windows</a> blog...

require 'win32ole'

WdStatisticWords = 0
WdStatisticPages = 2

word = WIN32OLE.connect('Word.Application')
doc = word.ActiveDocument
word_count = doc.ComputeStatistics(WdStatisticWords)
page_count = doc.ComputeStatistics(WdStatisticPages)

Further details <a href="">here</a>.