Prevent a user from using a file that is open in Excel
Charliecherche
Posted messages
2
Registration date
Status
Member
Last intervention
-
Psy-no-pb -
Psy-no-pb -
Hello,
I want to set an Excel file to read-only if another user attempts to modify it when it is already open.
4 answers
-
Hello,
Why not set it to read-only all the time?
Daniel
-
Hello,
See here: Set or clear read-only status in Excel for Mac | Microsoft Support
Best regards.
Le Pingou -
Otherwise, but I don’t see much point, per macro. Put this code in the "ThisWorkbook" module:
Private Sub Workbook_BeforeClose(Cancel As Boolean) SetAttr "D:\OneDrive\mpfe\lectureseule.xlsm", vbNormal End Sub Private Sub Workbook_Open() SetAttr "D:\OneDrive\mpfe\lectureseule.xlsm", vbReadOnly End Sub
By replacing the path and file name (and again, this is to be tested). Then, you will need to modify the file to be (roughly) sure that VBA is enabled. And lock the VBA project. If you want details, ask.
Daniel
PS. It doesn’t prevent modifications, it prevents saving them.
-
Hello,
""
Lock or unlock a workbook to make it read-only
- From the File menu, select Always open read-only. ...
- To require a password, in the File menu, select Passwords and enter a password to open the file.