Suppress Read-only and notify message box

newvbie

Board Regular
Joined
Mar 18, 2006
Messages
69
Hi there. Can I use vba to suppress the "read-only ,notify, cancel" message box when the read only file (which is being opened by other user) is opened by a another user? I want a tailor-made message box is used instead.

Cheers.
 

Some videos you may like

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

stuartford

Active Member
Joined
Nov 28, 2002
Messages
419
Application.DisplayAlerts = False

might work for you

if you put it in the This Workbook

module to run on start up and then turn it to True upon close

ive not tested this but im confident it should wok

Stu
 

newvbie

Board Regular
Joined
Mar 18, 2006
Messages
69
Hi there. Thanks for your reply. However, I have tried your advice but the message box still pops up if the file is opened by someone. I placed the expression in the thisworkbook module as follows:

Code:
Private Sub Workbook_Open()
    Dim sUserName As String
    Application.DisplayAlerts = False
If ActiveWorkbook.ReadOnly Then
sUserName = "[ " & Sheet2.Range("bd4").Value & " ]"

sMsg2 = "Sorry!  This leave plan is now being used by " & vbCrLf
sMsg3 = vbCrLf & "  ....Please try again minutes later..."
        MsgBox sMsg2 & vbCrLf & "           " & sUserName & vbCrLf & sMsg3, vbCritical, "Filed being used"
     Application.Quit
    ActiveWorkbook.Close
    Application.DisplayAlerts = True
    Exit Sub
endIf

Any advice?

Cheers.
 

Watch MrExcel Video

Forum statistics

Threads
1,114,675
Messages
5,549,367
Members
410,911
Latest member
AniEx
Top