Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to make Excel file read only?

Status
Not open for further replies.

EwS

Programmer
Dec 30, 2002
398
US
I am creating an Excel file programmatically. I would like to make it read only. How can I do this?
Thank you.
 
And I also need a way of making the read-only file writable programmatically.
 
File.SetAttributes(fileName, FileAttributes.ReadOnly)
File.SetAttributes(fileName, FileAttributes.Normal)
 
There should also be a set of methods availible on the workbook object to Protect the document from making changes similar to this.

Protect(Read Only):
Application.ActiveWorkbook.Protect("password", True, True)

Unprotect(Modify/Write):
Application.ActiveWorkbook.Unprotect("password")

Senior Software Developer
 
At a previous position (i.e. they have the code) I created Excel files and locked them but do not remember the code. The Password idea is useful but was not what I used.

Check Microsoft's KB for how to examples.

Good Luck
djj
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top