PDA

View Full Version : Worksheet ReadOnly?



bopo
01-23-2007, 02:30 PM
Hi

Basically I want a worksheet to become read only, is there any way of implementing this?

Simon Lloyd
01-23-2007, 02:38 PM
To make a worksheet read only you would need to make sure cells are locked and then apply worksheet protection, however to make a workbook read only you could use this:

Private Sub Workbook_Open()
ThisWorkbook.ChangeFileAccess xlReadOnly
End Sub
then everytime your workbook is opened it will be read only!

Regards,
SImon

maytas
01-23-2007, 02:41 PM
Hi

Basically I want a worksheet to become read only, is there any way of implementing this?
worksheet -> WorkBook.
Set WB = Workbooks.Open("C:\FolderName\WorkBookName.xls", False, True)

Ken Puls
01-24-2007, 12:08 PM
For worksheets:
Worksheets("Sheet1").Protect Password:="MyPassword", userinterfaceonly:=True

Change the sheet name (or put it in a loop), and change the password or elminate it all together. The UserInterfaceOnly argument sets it to allow macros to run on the worksheet, but prevent users from editing "locked" fields.

Be warned that the UserInterfaceOnly setting does not persist when Excel is closed. If you want that feature, I'd suggest a routine called from your Workbook_Open routine that re-protects the applicable sheets.

HTH,