ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Force Read-Only? (https://www.excelbanter.com/excel-programming/272245-force-read-only.html)

Ed[_9_]

Force Read-Only?
 
I share a workbook (Excel 2000) on a company-wide server. The users will
filter and hide columns and rows, and I'm afraid someone will save the
changes so the next user opens up a file of garbage. I can right-click the
file icon and set the properties to Read-Only, but someone can simply change
it back, then do their damage.

Is it possible to create a BeforeOpen event that will force this to
Read-Only, regardless of what the user has done before opening the file?

Ed



John Wilson

Force Read-Only?
 
Ed,

In the Workbook_Open Event......

Private Sub Workbook_Open()
If ActiveWorkbook.ReadOnly = False Then
ThisWorkbook.Saved = True
ThisWorkbook.ChangeFileAccess xlReadOnly
End If
End Sub

Note though that the user could still get to the VBA Editor and type
the following into the Immediate window:
ThisWorkbook.ChangeFileAccess xlReadWrite
To change it back.

John

Ed wrote:

I share a workbook (Excel 2000) on a company-wide server. The users will
filter and hide columns and rows, and I'm afraid someone will save the
changes so the next user opens up a file of garbage. I can right-click the
file icon and set the properties to Read-Only, but someone can simply change
it back, then do their damage.

Is it possible to create a BeforeOpen event that will force this to
Read-Only, regardless of what the user has done before opening the file?

Ed



Ed[_9_]

Force Read-Only?
 
Thank you, John. This may have solved a big issue for me.

I'm not so worried about a our users going into the code. Most of them are
"trained" well enough not to do that. But we do have ways of tracking down
the others.

Ed


"John Wilson" wrote in message
...
Ed,

In the Workbook_Open Event......

Private Sub Workbook_Open()
If ActiveWorkbook.ReadOnly = False Then
ThisWorkbook.Saved = True
ThisWorkbook.ChangeFileAccess xlReadOnly
End If
End Sub

Note though that the user could still get to the VBA Editor and type
the following into the Immediate window:
ThisWorkbook.ChangeFileAccess xlReadWrite
To change it back.

John





All times are GMT +1. The time now is 05:16 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com