Can we use MS Word Template using Ruby


#1

Hi all,
I am creating MS word document using ruby. can I use a “template”
document in Microsoft word with place holders for dynamic data from
database using ruby.
Like, I’ve a template, I want to fill it by data from database, using
ruby.
Please help me out.

Thanks,


#2

As far as i can see, just use ‘open’ on the template file instead of a
normal document. Don’t use this file to save though.

Again, this is the Ruby on Rails board. Please ask Win32OLE-specific
questions at the ruby board. Second, Rubys Win32OLE gives you
everything that can be accomplished with OLE. Please refer to the
corresponding documentation or the msdn. As your questions are not on
how to use OLE but which part of OLE to use, this might be a better
idea.

Thanks
Skade


#3

aveo wrote:

Hi all,
I am creating MS word document using ruby. can I use a “template”
document in Microsoft word with place holders for dynamic data from
database using ruby.
Like, I’ve a template, I want to fill it by data from database, using
ruby.
Please help me out.

Thanks,

As Skade mentioned, open the template as you would a regular document…

word = WIN32OLE.new(‘Word.Application’)
doc = word.Documents.Open(‘Contemporary Resume.dot’)

…and save it as a regular document…

doc.SaveAs(‘Contemporary Resume.doc’)

As mentioned, you’ll want to take this particular topic off this board.
Feel free to visit my blog and/or send email with questions about Ruby
and Windows, MS Office, etc.

David
http://rubyonwindows.blogspot.com