471,354 Members | 1,191 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,354 software developers and data experts.

Need example: Add password to Excel file.

Greetings,

I have an existing Excel file. I need to programatically password protect
the file so that it can't be read unless the password is entered.

Any code examples?

Thanks!

[c# 2005]
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Best free software
http://www.vbmark.com
Freeware-dedicated search engine
http://www.eurekster.com/parties/Freeware1.htm
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Dec 2 '05 #1
2 8499
vbMark,

All you have to do is call the SaveAs method on the workbook. There is
a Password parameter that you set to the password you want to be used for
opening the workbook.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"vbMark" <no@email.com> wrote in message
news:Xn********************@199.45.49.11...
Greetings,

I have an existing Excel file. I need to programatically password protect
the file so that it can't be read unless the password is entered.

Any code examples?

Thanks!

[c# 2005]
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Best free software
http://www.vbmark.com
Freeware-dedicated search engine
http://www.eurekster.com/parties/Freeware1.htm
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Dec 2 '05 #2
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in news:ur*************@TK2MSFTNGP09.phx.gbl:
vbMark,

All you have to do is call the SaveAs method on the workbook.
There is
a Password parameter that you set to the password you want to be used
for opening the workbook.

Hope this helps.


Worked great. Thanks!

--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Best free software
http://www.vbmark.com
Freeware-dedicated search engine
http://www.eurekster.com/parties/Freeware1.htm
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Dec 2 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by dmateer | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.