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

JackDanIce

Well-known Member
Joined
Feb 3, 2010
Messages
9,900
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

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

Jaafar Tribak

Well-known Member
Joined
Dec 5, 2002
Messages
9,155
Office Version
  1. 2016
Platform
  1. Windows
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

JackDanIce

Well-known Member
Joined
Feb 3, 2010
Messages
9,900
Office Version
  1. 365
Platform
  1. Windows
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,191,183
Messages
5,985,172
Members
439,944
Latest member
Vangelis74

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
Top