# Win32ole encript document excel

**URL:** <https://www.ruby-forum.com/t/win32ole-encript-document-excel/148464>\
**Category:** Ruby\
**Created:** [September 13, 2008, 1:55am UTC](https://www.ruby-forum.com/t/win32ole-encript-document-excel/148464 "2008-09-13T01:55:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ivmafo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/6f9a4e/32.png) [@ivmafo](https://www.ruby-forum.com/u/ivmafo)\
**Post date:** [September 13, 2008, 1:55am UTC](https://www.ruby-forum.com/t/win32ole-encript-document-excel/148464/1 "2008-09-13T01:55:39Z")

</div>

does anybody how to protect a excel document made with ruby and then put  
a password /??

---

<div class="post-metadata">

**Author:** ![ivmafo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/6f9a4e/32.png) [@ivmafo](https://www.ruby-forum.com/u/ivmafo)\
**Post date:** [September 13, 2008, 4:22pm UTC](https://www.ruby-forum.com/t/win32ole-encript-document-excel/148464/2 "2008-09-13T16:22:17Z")

</div>

Foreero I. wrote:

> does anybody how to protect a excel document made with ruby and then put  
> a password /??

To password-protect an Excel workbook, set the workbook object’s  
Password property before calling the SaveAs() method:

wb.Password = ‘MyPassword’  
wb.SaveAs(‘c:\temp\xlpsw.xls’)

To open a password-protected workbook, either call the standard Open()  
method…

wb = xl.Workbooks.Open(‘c:\temp\xlpsw.xls’)

…and then you will be prompted to enter the password…

…or pass the password as an argument hash to the Open() method:

wb = xl.Workbooks.Open(‘c:\temp\xlpsw.xls’, {‘password’ =\>  
‘MyPassword’})

Hope that helps.

David

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

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

---

<div class="post-metadata">

**Author:** ![ivmafo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/6f9a4e/32.png) [@ivmafo](https://www.ruby-forum.com/u/ivmafo)\
**Post date:** [September 13, 2008, 5:27pm UTC](https://www.ruby-forum.com/t/win32ole-encript-document-excel/148464/3 "2008-09-13T17:27:19Z")

</div>

Thanks !!!
