Looking for Win32OLE sample code (Tables in Word)

Hi

I am looking for some sample code (or OLE reference)
that will let me write some simple tables into a word
doc using ruby and win32ole.

Any pointers would be greatly appreciated.

Thanks

···


Jim Freeze

Those who can, do. Those who can’t, simulate.

Hi

···

On Wed, 28 Jan 2004, Jim Freeze wrote:

I am looking for some sample code (or OLE reference)

that will let me write some simple tables into a word

doc using ruby and win32ole.

Any pointers would be greatly appreciated.

require 'win32ole’
word = WIN32OLE.new(“Word.Application”)
word.visible = true
word.documents.add
word.ActiveDocument.Tables.Add(Word.selection.range, 4, 2)
selection = word.selection
4.times {
selection.typetext "Hello"
selection.moveright
selection.typetext "World!"
selection.moveright
selection.moveright
}

Brian Marick also has a really nice article on his website about using
Ruby as a testing tool for Windows applications. He uses Word as the
example application:

Chad