Forum: Ruby on Rails can we use MS Word Template using Ruby

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
D69cd9081a425b5c8b5efa6b0633135c?d=identicon&s=25 aveo (Guest)
on 2007-04-11 14:10
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,
D1f1c20467562fc1d8c8aa0d328def62?d=identicon&s=25 Florian Gilcher (skade)
on 2007-04-11 16:11
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
Bfa670ef2303deb7dec5a8027367b30b?d=identicon&s=25 David Mullet (mully)
on 2007-04-12 04:38
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
This topic is locked and can not be replied to.