# Can we use MS Word Template using Ruby

**URL:** <https://www.ruby-forum.com/t/can-we-use-ms-word-template-using-ruby/91677>\
**Category:** Rails\
**Created:** [April 11, 2007, 2:10pm UTC](https://www.ruby-forum.com/t/can-we-use-ms-word-template-using-ruby/91677 "2007-04-11T14:10:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aveo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/aeb1de/32.png) [@aveo](https://www.ruby-forum.com/u/aveo)\
**Post date:** [April 11, 2007, 2:10pm UTC](https://www.ruby-forum.com/t/can-we-use-ms-word-template-using-ruby/91677/1 "2007-04-11T14:10:51Z")

</div>

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,

---

<div class="post-metadata">

**Author:** ![aveo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/aeb1de/32.png) [@aveo](https://www.ruby-forum.com/u/aveo)\
**Post date:** [April 11, 2007, 4:11pm UTC](https://www.ruby-forum.com/t/can-we-use-ms-word-template-using-ruby/91677/2 "2007-04-11T16:11:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![aveo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/aeb1de/32.png) [@aveo](https://www.ruby-forum.com/u/aveo)\
**Post date:** [April 12, 2007, 4:38am UTC](https://www.ruby-forum.com/t/can-we-use-ms-word-template-using-ruby/91677/3 "2007-04-12T04:38:04Z")

</div>

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

> **[Ruby on Windows](http://rubyonwindows.blogspot.com)**
>
> On using the Ruby programming language on the Microsoft Windows platform
