Close duplicate copy of a file is open; close it without save prompt

JackDanIce

Well-known Member
Joined
Feb 3, 2010
Messages
9,922
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have a workbook which sometimes is open on one person's PC and then a second person opens it.

When the second person opens it, it provides the "READ ONLY", "NOTIFY" and "CANCEL" prompts.

(i) If it has been opened as "READ ONLY", what code can I use in the workbook code to close it without the save prompt? I.e. kill/delete the temporary copy of the file

(ii) In addition, can I remove the "NOTIFY" option when the second person tries to open this file?

Apologies if this should be as seperate threads, I'm more interested in the answer to (i) but if (ii) can be solved at the same time, then great - both seem related.

Thanks in advance,
Jack
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Maybe something along these lines for Q1

Code:
Option Explicit

Private Sub Workbook_BeforeClose(Cancel As Boolean)

    If Me.ReadOnly Then
        Me.Saved = True
    End If

End Sub

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)

    If Me.ReadOnly Then
        Cancel = True
        MsgBox "Sorry,you can't save this workbook."
    End If

End Sub
Obviously, this is assuming the user has the Macros enabled.
 
Last edited:
Upvote 0
Thanks Jaafar, will test shortly, but they look like they'll work. Like your signature quote too, nice one.
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,561
Members
449,089
Latest member
Motoracer88

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