Do not open run if workbook is read only.

Draconas1988

New Member
Joined
Jan 10, 2019
Messages
1
Hey,

I have an excel sheet that multiple users will need to access at various times. I've recently run into the issue where a few of them have tried to open it at the same time as another, enter data, and try to save it while it is in read only. I tried a few macros to keep them from opening the workbook up while another user was in it but to little success.

So instead is there a way I can make it so the button will not open the form if the workbook is read only?

Thanks.
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
It would be difficult to keep them from opening it, but you could put code like that shown below in the workbook open event to warn them, and optionally close the workbook.

Code:
Sub CheckWriteStatus()
    Dim Msg As String, Title As String, Ans As Integer
    Dim ReadOnly As Boolean

    Msg = "This file is currently read only and may be in use by another user"
    Title = "Warning"

    ReadOnly = GetAttr(ThisWorkbook.FullName) And vbReadOnly

    If ReadOnly Then
        MsgBox Msg, vbExclamation, Title
        ThisWorkbook.Close False
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,286
Members
452,631
Latest member
a_potato

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