Prevent people from opening a read only

Metaripley

Board Regular
Joined
Dec 31, 2014
Messages
93
I have a excel workbook where multiple people work in (not shared).

But I want to prevent that people create data and then dont save. I can make a macro for them to automatically save every change they do.
But when people work in a read only version (because someone else has the file open) they cannot save or save a local version which is not allowed.

So can i prevent them from opening the file when it is read only? So they first have to ask the other person to close it before they can open it and everything is always saved?
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Explain to your people that they MUST NOT work in a read only version because changes will be lost when they close the read only version. Get them all to sign a statement saying that they understand this instruction, and will obey it. This should "remind" them not to do it.
 
Upvote 0
People will be people, I dont know ho is or is going to use it.
I just need a foolproof excel.

I found this online but it is not working:

Code:
Sub Workbook_Open()    If ActiveWorkbook.ReadOnly Then ActiveWorkbook.Close False
    End If
  
  End Sub
 
Upvote 0
if you are using workbook1, and I try to open workbook1, I am offered a read only copy. I say yes, and it opens, an exact copy of the workbook1, maybe before you opened it. So you need to figure out how to run a macro in my read only, as soon as I open it. I believe there is a way to trigger a macro with any key stroke, ******* or something. But beyond me, sorry.
 
Upvote 0
Hi
Try this
Code:
Sub Workbook_Open()

    If Me.ReadOnly Then
        MsgBox "This file is readonly & will close"
        ActiveWorkbook.Close False
    End If
  
End Sub
It will bring up a message box to alert the user what is happening.
Otherwise they may just think something has gone wrong, & keep trying to open it.
 
Upvote 0
Hi
Try this
Code:
Sub Workbook_Open()

    If Me.ReadOnly Then
        MsgBox "This file is readonly & will close"
        ActiveWorkbook.Close False
    End If
  
End Sub
It will bring up a message box to alert the user what is happening.
Otherwise they may just think something has gone wrong, & keep trying to open it.

Thanks! Works great!
(works only in sheet code and not in workbook code)
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top